簡介
plot1cell
包提供了多種單細胞數(shù)據(jù)可視化的高級功能,可以基于Seurat分析結(jié)果對象直接進行可視化繪圖属桦,主要依賴于Seurat V4匠题,circlize,ComplexHeatmap和simplifyEnrichment等R包晤碘。
R包安裝
使用devtools包進行安裝:
devtools::install_github("TheHumphreysLab/plot1cell")
## or the development version, devtools::install_github("HaojiaWu/plot1cell")
## You might need to install the dependencies below if they are not available in your R library.
bioc.packages <- c("biomaRt","GenomeInfoDb","EnsDb.Hsapiens.v86","GEOquery","simplifyEnrichment","ComplexHeatmap")
BiocManager::install(bioc.packages)
dev.packages <- c("chris-mcginnis-ucsf/DoubletFinder","Novartis/hdf5r","mojaveazure/loomR")
devtools::install_github(dev.packages)
## If you can't get the hdf5r package installed, please see the fix here:
## https://github.com/hhoeflin/hdf5r/issues/94
示例數(shù)據(jù)演示
plot1cell包可以基于Seurat的細胞聚類分群注釋結(jié)果進行后續(xù)的可視化繪圖,在本教程中功蜓,我們使用 Kirita et al, PNAS 2020文章中的Seurat結(jié)果對象進行可視化演示园爷,該數(shù)據(jù)已上傳至GEO (GSE139107)數(shù)據(jù)庫中。
library(plot1cell)
iri.integrated <- Install.example()
# Please note that this Seurat object is just for demo purpose and
# is not exactly the same as the one we published on PNAS.
# It takes about 2 hours to run in a linux server with 500GB RAM and 32 CPU cores.
# You can skip this step and use your own Seurat object instead
1. 繪制細胞聚類分群和注釋信息的圈圖
在plot1cell包中霞赫,我們可以使用plot_circlize
函數(shù)繪制細胞聚類分群的圈圖腮介,使用add_track
函數(shù)添加不同細胞注釋信息。
###Check and see the meta data info on your Seurat object
colnames(iri.integrated@meta.data)
###Prepare data for ploting 準備圈圖數(shù)據(jù)
circ_data <- prepare_circlize_data(iri.integrated, scale = 0.8 )
set.seed(1234)
# 設(shè)置細胞分群信息的顏色
cluster_colors<-rand_color(length(levels(iri.integrated)))
group_colors<-rand_color(length(names(table(iri.integrated$Group))))
rep_colors<-rand_color(length(names(table(iri.integrated$orig.ident))))
###plot and save figures
# 繪制細胞分群圈圖
png(filename = 'circlize_plot.png', width = 6, height = 6,units = 'in', res = 300)
plot_circlize(circ_data,do.label = T, pt.size = 0.01, col.use = cluster_colors ,bg.color = 'white', kde2d.n = 200, repel = T, label.cex = 0.6)
# 添加細胞群注釋信息
add_track(circ_data, group = "Group", colors = group_colors, track_num = 2) ## can change it to one of the columns in the meta data of your seurat object
add_track(circ_data, group = "orig.ident",colors = rep_colors, track_num = 3) ## can change it to one of the columns in the meta data of your seurat object
dev.off()
2. 繪制基因表達氣泡圖
使用complex_dotplot_single
函數(shù)繪制單個基因在不同細胞分組中的基因表達氣泡圖端衰。
png(filename = 'dotplot_single.png', width = 4, height = 6,units = 'in', res = 100)
complex_dotplot_single(seu_obj = iri.integrated, feature = "Havcr1",groups = "Group")
dev.off()
設(shè)置groups
和splitby
參數(shù)對多個分組信息進行分割繪圖。
iri.integrated@meta.data$Phase<-plyr::mapvalues(iri.integrated@meta.data$Group, from = levels(iri.integrated@meta.data$Group), to = c("Healthy",rep("Injury",3), rep("Recovery",2)))
iri.integrated@meta.data$Phase<-as.character(iri.integrated@meta.data$Phase)
png(filename = 'dotplot_single_split.png', width = 4, height = 6,units = 'in', res = 100)
complex_dotplot_single(iri.integrated, feature = "Havcr1",groups = "Group",splitby = "Phase")
dev.off()
png(filename = 'dotplot_more_groups.png', width = 8, height = 6,units = 'in', res = 100)
complex_dotplot_single(seu_obj = iri.integrated, feature = "Havcr1",groups= c("Group","Replicates"))
dev.off()
iri.integrated@meta.data$ReplicateID<-plyr::mapvalues(iri.integrated@meta.data$Replicates, from = names(table((iri.integrated@meta.data$Replicates))), to = c(rep("Rep1",3),rep("Rep2",3), rep("Rep3",1)))
iri.integrated@meta.data$ReplicateID<-as.character(iri.integrated@meta.data$ReplicateID)
png(filename = 'dotplot_more_groups_split.png', width = 9, height = 6,units = 'in', res = 200)
complex_dotplot_single(seu_obj = iri.integrated, feature = "Havcr1",groups= c("Group","Replicates"), splitby = c("Phase","ReplicateID"))
dev.off()
### In this example, "Phase" is a splitby factor for "Group" and "ReplicateID" is a splitby factor for "Replicates".
使用complex_dotplot_multiple
函數(shù)繪制多個基因的表達氣泡圖甘改。
png(filename = 'dotplot_multiple.png', width = 10, height = 4,units = 'in', res = 300)
complex_dotplot_multiple(seu_obj = iri.integrated, features = c("Slc34a1","Slc7a13","Havcr1","Krt20","Vcam1"),group = "Group", celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"))
dev.off()
3. 繪制基因表達小提琴圖
使用complex_vlnplot_single
函數(shù)繪單個基因在不同細胞分組中的基因表達小提琴圖旅东。
png(filename = 'vlnplot_single.png', width = 4, height = 6,units = 'in', res = 100)
complex_vlnplot_single(iri.integrated, feature = "Havcr1", groups = "Group",celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"))
dev.off()
類似的,我們同樣可以設(shè)置groups
和splitby
參數(shù)對多個分組信息進行分割繪圖十艾。
png(filename = 'vlnplot_single_split.png', width = 4, height = 6,units = 'in', res = 100)
complex_vlnplot_single(iri.integrated, feature = "Havcr1", groups = "Group",celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"), splitby = "Phase")
dev.off()
png(filename = 'vlnplot_multiple.png', width = 6, height = 6,units = 'in', res = 100)
complex_vlnplot_single(iri.integrated, feature = "Havcr1", groups = c("Group","Replicates"),celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"), font.size = 10)
dev.off()
png(filename = 'vlnplot_multiple_split.png', width = 7, height = 5,units = 'in', res = 200)
complex_vlnplot_single(iri.integrated, feature = "Havcr1", groups = c("Group","Replicates"),
celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"),
font.size = 10, splitby = c("Phase","ReplicateID"), pt.size=0.05)
dev.off()
使用complex_vlnplot_multiple
函數(shù)繪制多個基因的表達小提琴圖抵代。
png(filename = 'vlnplot_multiple_genes.png', width = 6, height = 6,units = 'in', res = 300)
complex_vlnplot_multiple(iri.integrated, features = c("Havcr1", "Slc34a1", "Vcam1", "Krt20" , "Slc7a13", "Slc5a12"), celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"), group = "Group", add.dot=T, pt.size=0.01, alpha=0.01, font.size = 10)
dev.off()
4. 繪制基因表達feature plot
使用complex_featureplot
函數(shù)繪制不同基因在不同細胞分組中的基因表達feature plot。
png(filename = 'data/geneplot_umap.png', width = 8, height = 6,units = 'in', res = 100)
complex_featureplot(iri.integrated, features = c("Havcr1", "Slc34a1", "Vcam1", "Krt20" , "Slc7a13"), group = "Group", select = c("Control","12hours","6weeks"), order = F)
dev.off()
5. 繪制差異基因表達熱圖
plot1cell包可以直接鑒定不同條件下細胞類型的差異表達基因忘嫉,并基于ComplexHeatmap包繪制差異基因的表達熱圖荤牍。
iri.integrated$Group2<-plyr::mapvalues(iri.integrated$Group, from = c("Control", "4hours", "12hours", "2days", "14days" , "6weeks" ),
to = c("Ctrl","Hr4","Hr12","Day2", "Day14","Wk6"))
iri.integrated$Group2<-factor(iri.integrated$Group2, levels = c("Ctrl","Hr4","Hr12","Day2", "Day14","Wk6"))
png(filename = 'heatmap_group.png', width = 4, height = 8,units = 'in', res = 100)
complex_heatmap_unique(seu_obj = iri.integrated, celltype = "NewPT2", group = "Group2",gene_highlight = c("Slc22a28","Vcam1","Krt20","Havcr1"))
dev.off()
6. 繪制差異基因overlap的集合圖
我們可以使用complex_upset_plot
函數(shù)繪制不同組細胞群間差異表達基因overlap的集合圖。
png(filename = 'upset_plot.png', width = 8, height = 4,units = 'in', res = 300)
complex_upset_plot(iri.integrated, celltype = "NewPT2", group = "Group", min_size = 10, logfc=0.5)
dev.off()
7. 繪制細胞比例分布柱狀圖
我們可以使用plot_cell_fraction
函數(shù)繪制不同組細胞比例分布的柱狀圖庆冕。
png(filename = 'cell_fraction.png', width = 8, height = 4,units = 'in', res = 300)
plot_cell_fraction(iri.integrated, celltypes = c("PTS1" , "PTS2" , "PTS3" , "NewPT1" , "NewPT2"), groupby = "Group", show_replicate = T, rep_colname = "orig.ident")
dev.off()
8. 其他繪圖功能
使用help()函數(shù)查看該包的其他高級繪圖功能康吵。
help(package = plot1cell)
引用
Please consider citing our paper if you find plot1cell
useful.
https://www.cell.com/cell-metabolism/fulltext/S1550-4131(22)00192-9
Cell Metab. 2022 Jul 5;34(7):1064-1078.e6.
Wu H, Gonzalez Villalobos R, Yao X, Reilly D, Chen T, Rankin M, Myshkin E, Breyer MD, Humphreys BD.
Mapping the single-cell transcriptomic response of murine diabetic kidney disease to therapies.