> gene_list <- genes
> plot_list <- list()
> i = 1
> for (gene in gene_list){
+ Gene_df <- object[['Spatial']]@counts %>% as.data.frame() %>% rownames_to_column(var = 'Gene') %>%
filter(Gene == gene) %>% melt() %>% rename(Barcode = variable, nCount = value) %>%
left_join(barcode_pos, by = 'Barcode') %>% dplyr::select(.,-Gene)
+ Gene_heatmap <- ggplot(Gene_df, aes(x = pos_w, y = (dim(png)[1] - pos_h)))+
background_image(png)+
geom_point(shape = 16, size = 1, aes(color = nCount, alpha = nCount))+
coord_cartesian(xlim = c(0, dim(png)[2]), ylim = c(0, dim(png)[1]),expand = FALSE)+
scale_alpha_continuous(range = c(0.85,1))+
scale_color_gradientn(colours = c('#313695','#6ca4cc','#cfebf3','#fee99d','#f67d4a','#b91426'))+
#scale_color_continuous(low = '#b4cf66', high = '#9b2a14')+
guides(alpha = 'none')+
theme(axis.title.x=element_blank(),axis.text.x=element_blank(),
axis.ticks.x=element_blank(), axis.title.y=element_blank(),
axis.text.y=element_blank(),axis.ticks.y=element_blank(),
plot.title = element_text(size = 14,face = "bold", hjust = 0.5))+
labs(x = NULL, y = NULL, title = gene, alpha = NULL)
plot_list[[i]] <- Gene_heatmap
i = i + 1
+ }
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
Using Gene as id variables
> plot_grid(plotlist=plot_list,ncol=2)
> plot_grid(plotlist=plot_list,ncol=2,labels="AUTO")
> plot_grid(plotlist=plot_list,ncol=2,labels=c("cluster1","cluster1","cluster1","cluster4","cluster4","cluster8","cluster8","cluster8"))
> plot_grid(plotlist=plot_list,ncol=2,labels=c("cluster1","cluster1","cluster1","cluster4","cluster4","cluster8","cluster8","cluster8"),label_size=8)
> pdf("specific_and_high_expression_gene.pdf")
> plot_grid(plotlist=plot_list,ncol=2,labels=c("cluster1","cluster1","cluster1","cluster4","cluster4","cluster8","cluster8","cluster8"),label_size=8)
plot_grid多图组合
最新推荐文章于 2024-06-26 09:13:07 发布