title: “Heart_deconvolution”
#https://github.com/rdong08/spatialDWLS_dataset
output: html_document

#https://github.com/rdong08/spatialDWLS_dataset/blob/main/codes/Heart_ST_tutorial_spatialDWLS.Rmd

##Import library

```{r}

library(Giotto)
library(ggplot2)
library(scatterpie)
library(data.table)
#getwd() path="G:/silicosis/sicosis/gitto/heart_visu_deconv/" setwd(path) ##Here is an example for tutorial by using spatial transcriptomic data of Sample 10, W6 in Asp et al. ##Identification of marker gene expression in single cell #{r}
#sc_meta<-read.table("…/datasets/heart_development_ST/sc_meta.txt",header = F,row.names = 1)
#sc_data<-read.table("…/datasets/heart_development_ST/all_cells_count_matrix_filtered.tsv",header = T,row.names = 1)

sc_meta=read.table(“G:/silicosis/sicosis/gitto/heart_visu_deconv/sc_meta.txt”,
header =FALSE,row.names = 1)
head(sc_meta)

sc_data<-read.table(“G:/silicosis/sicosis/gitto/heart_visu_deconv/all_cells_count_matrix_filtered.tsv/all_cells_count_matrix_filtered.tsv”,
header = T,row.names = 1)
head(sc_data)


my_python_path = “python path”
instrs = createGiottoInstructions(python_path = my_python_path)
heart_sc <- createGiottoObject(raw_exprs = sc_data,
instructions = instrs)

heart_sc <- normalizeGiotto(gobject = heart_sc, scalefactor = 6000, verbose = T)

heart_sc <- calculateHVG(gobject = heart_sc)

gene_metadata = fDataDT(heart_sc)
featgenes = gene_metadata[hvg == ‘yes’]$gene_ID

heart_sc <- runPCA(gobject = heart_sc, genes_to_use = featgenes, scale_unit = F)
signPCA(heart_sc, genes_to_use = featgenes, scale_unit = F)

#######calculate Sig for deconvolution, This step use DEG function implemented in Giotto

heart_sc@cell_metadata$leiden_clus <- as.character(sc_meta$V3)

scran_markers_subclusters = findMarkers_one_vs_all(gobject = heart_sc,
method = ‘scran’,
expression_values = ‘normalized’,
cluster_column = ‘leiden_clus’)

Sig_scran <- unique(scran_markers_subclustersgenes[which(scranmarkerssubclustersgenes[which(scran_markers_subclustersgenes[which(scranm​arkerss​ubclustersranking <= 100)])

########Calculate median expression value of signature genes in each cell type

norm_exp<-2^(heart_sc@norm_expr)-1

id<-heart_sc@cell_metadata$leiden_clus
ExprSubset<-norm_exp[Sig_scran,]

Sig_exp<-NULL

for (i in unique(id)){
Sig_exp<-cbind(Sig_exp,(apply(ExprSubset,1,function(y) mean(y[which(id==i)]))))
}
colnames(Sig_exp)<-unique(id)
#```

##Spatial transcriptomic data analysis
#```{r}
##The heart spatial transcriptomic data is from Asp et al “A Spatiotemporal Organ-Wide Gene Expression and Cell Atlas of the Developing Human Heart”.
spatial_loc<-read.table(file="…/datasets/heart_development_ST/sample10_w6_loc.txt",header = F)

spatial_exp<-read.table(file="…/datasets/heart_development_ST/sample10_w6_exp.txt",header = T,row.names = 1)

##Transform ensemble gene to official gene name
ens2gene<-read.table(file="…/datasets/heart_development_ST/ens2symbol.txt",row.names = 1)

inter_ens<-intersect(rownames(spatial_exp),rownames(ens2gene))

filter_spatial_exp<-spatial_exp[inter_ens,]
rownames(filter_spatial_exp)<-as.character(ens2gene[inter_ens,])

##Generate Giotto objects and cluster spots
heart_w6_sample10_st <- createGiottoObject(raw_exprs = filter_spatial_exp,spatial_locs = spatial_loc,
instructions = instrs)
heart_w6_sample10_st <- filterGiotto(gobject = heart_w6_sample10_st,
expression_threshold = 1,
gene_det_in_min_cells = 10,
min_det_genes_per_cell = 200,
expression_values = c(‘raw’),
verbose = T)

heart_w6_sample10_st <- normalizeGiotto(gobject = heart_w6_sample10_st)
heart_w6_sample10_st <- calculateHVG(gobject = heart_w6_sample10_st)
gene_metadata = fDataDT(heart_w6_sample10_st)

featgenes = gene_metadata[hvg == ‘yes’]$gene_ID
heart_w6_sample10_st <- runPCA(gobject = heart_w6_sample10_st, genes_to_use = featgenes, scale_unit = F)
signPCA(heart_w6_sample10_st, genes_to_use = featgenes, scale_unit = F)

heart_w6_sample10_st <- createNearestNetwork(gobject = heart_w6_sample10_st, dimensions_to_use = 1:10, k = 10)
heart_w6_sample10_st <- doLeidenCluster(gobject = heart_w6_sample10_st, resolution = 0.4, n_iterations = 1000)
##Deconvolution based on signature gene expression and Giotto object
heart_w6_sample10_st <- runDWLSDeconv(gobject = heart_w6_sample10_st, sign_matrix = Sig_exp)
##The result for deconvolution is stored in heart_w6_sample10_st@spatial_enrichmentDWLS.Thefollowingcodesarevisualizationdeconvolutionresultsusingpieplotplotdata<−as.data.frame(heartw6sample10st@spatialenrichmentDWLS. The following codes are visualization deconvolution results using pie plot plot_data <- as.data.frame(heart_w6_sample10_st@spatial_enrichmentDWLS.Thefollowingcodesarevisualizationdeconvolutionresultsusingpieplotplotd​ata<−as.data.frame(heartw​6s​ample10s​t@spatiale​nrichmentDWLS)[-1]
plot_col <- colnames(plot_data)

plot_datax<−as.numeric(as.character(heartw6sample10st@spatiallocsx <- as.numeric(as.character(heart_w6_sample10_st@spatial_locsx<−as.numeric(as.character(heartw​6s​ample10s​t@spatiall​ocssdimx))
plot_datay<−as.numeric(as.character(heartw6sample10st@spatiallocsy <- as.numeric(as.character(heart_w6_sample10_st@spatial_locsy<−as.numeric(as.character(heartw​6s​ample10s​t@spatiall​ocssdimy))
min_x <- min(plot_datax)plotdatax) plot_datax)plotd​ataradius <- 0.4

df <- data.frame()
p <- ggplot(df) + geom_point() + xlim(min(plot_datax)−1,max(plotdatax)-1, max(plot_datax)−1,max(plotd​atax)+1) + ylim(min(plot_datay)−1,max(plotdatay)-1, max(plot_datay)−1,max(plotd​atay)+1)
p + geom_scatterpie(aes(x=x, y=y, r=radius), data=plot_data, cols=plot_col, color=NA, alpha=.8) +
geom_scatterpie_legend(plot_data$radius, x=1, y=1) + theme_classic()
#``

Heart_deconvolution giotto解卷积相关推荐

  1. Visium_Brain_deconvolution giotto解卷积

    title: "Visium_Brain_deconvolution" output: html_document #https://github.com/rdong08/spat ...

  2. 深度全解卷积神经网络(附论文)

    授权自AI科技大本营(ID: rgznai100) 本文共10315字,建议阅读10分钟. 本文帮你加深对卷积神经网络的理解,并对这个重要概念有一个全面的认知. [ 导读 ]深度卷积神经网络是这一波 ...

  3. 【 MATLAB 】z 变换中的卷积与解卷积

    关于卷积的博文,之前也写过几篇: [ MATLAB ]conv 函数介绍(卷积和多项式乘法) [ MATLAB ]两个序列的卷积和运算的MATLAB实现(1) [ MATLAB ]两个序列的卷积和运算 ...

  4. tensorflow学习笔记(三十二):conv2d_transpose (解卷积)

    tensorflow学习笔记(三十二):conv2d_transpose ("解卷积") deconv解卷积,实际是叫做conv_transpose, conv_transpose ...

  5. 深度学习(二十七)可视化理解卷积神经网络(反池化 pooling unpooling)

    不明白pooling,unpooling以及upsampling的区别,所以查阅了一些资料 以下为转载原文 可视化理解卷积神经网络 原文地址:http://blog.csdn.net/hjimce/a ...

  6. 深度学习元老Yann Lecun详解卷积神经网络

     深度学习元老Yann Lecun详解卷积神经网络 本文联合编译:Blake.高斐 雷锋网(公众号:雷锋网)注:卷积神经网络(Convolutional Neural Network)是一种前馈神 ...

  7. 深度学习(二十七)可视化理解卷积神经网络-ECCV 2014

    可视化理解卷积神经网络 原文地址:http://blog.csdn.net/hjimce/article/details/50544370 作者:hjimce 一.相关理论 本篇博文主要讲解2014年 ...

  8. DL之CNN:卷积神经网络算法简介之原理简介(步幅/填充/特征图)、七大层级结构(动态图详解卷积/池化+方块法理解卷积运算)、CNN各层作用及其可视化等之详细攻略

    DL之CNN:卷积神经网络算法简介之原理简介(步幅/填充/特征图).七大层级结构(动态图详解卷积/池化+方块法理解卷积运算).CNN各层作用及其可视化等之详细攻略 目录 CNN 的层级结构及相关概念 ...

  9. python cnn模型_ZfNet解卷积:可视化CNN模型( PythonCode可视化Cifar10)

    前言 由来已久,ANN方法被称为模式识别里面的"黑盒"方法,因为ANN模型不能使用明确的函数--形式化的数学公式进行表示,同时也意味着应对评价模型,面对函数寻求最优解的优化方程也不 ...

最新文章

  1. 将数组A中的内容和数组B中的内容进行交换(数组一样大)
  2. Atitit php序列化 php的serialize序列化和json序列化
  3. android 自定义相机源码,Android 自定义相机及分析源码
  4. 非常全面的阿里的Java面试题目,涵盖Java基础+高级+架构
  5. 花钱的最高境界是什么?
  6. NASA 传奇数学家去世,她曾笔算了登月轨道
  7. 0.0 研磨设计模式
  8. 基于SSM+Eclipse+MySQL的学生宿舍管理系统(SSM毕业设计源码)(学生宿舍管理系统毕业设计)
  9. 【kafka】kafka windows Invalid UTF-8 middle byte 0xfe
  10. lumion自动保存_lumion 保存在哪里? 我想在家里做 白天带到公司做 怎么操作 保存文件可以带走的吗?...
  11. win7看视频卡顿或声音画面不同步的解决步骤
  12. 双偶幻方的c语言算法,单偶阶、双偶阶幻方的巧妙填法
  13. 使用word完成海报制作说明书
  14. 解决黑苹果 App Store 无限输入密码的方法
  15. iOS根据图片比例计算显示大小
  16. OSChina 周五乱弹 ——下完雨朕的江山都湿了
  17. 前沿|开源项目DeepNav“无人船”修炼日记(一)
  18. 钉钉调用新版待办任务
  19. linux 命令查询主机名,主机名命令,linux查看主机名命令
  20. ITiM v2.0 功能框架

热门文章

  1. PHP 观察者模式 理解
  2. Windows7下网上银行U盾无法使用的解决办法
  3. 了解海外域名市场,把域名卖到全世界!
  4. 微软开始为厂商提供 SQL Server 2014 OTM
  5. BZOJ 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机 bfs
  6. python 爬陌生人qq空间_Python爬取qq空间说说
  7. IT:成为服务经纪人的未来
  8. 大蟒蛇python编译器_python蟒蛇绘制
  9. linux 路由器pppoe拨号,linux下pppoe拨号上网
  10. mybait——入门简单项目