SCI论文复现-UMAP图

该段代码使用R语言的多个库,如`Startrac`、`scPip`等,进行单细胞数据分析并绘制tsne散点图。主要展示了`CXCL13`、`IL7R`、`GZMK`和`ZNF683`基因在UMAP坐标系中的表达分布,通过调整图形主题、坐标轴范围和点的排列,生成了不同版本的散点图文件。
摘要由CSDN通过智能技术生成

在这里插入图片描述

		library("Startrac")
		library("scPip")
		library("sscVis")
		library("data.table")
		library("plyr")
		library("R.utils")
		library("ggpubr")
		library("ggplot2")
		source("./func.R")

###### a few genes (fig. S14A)
    {

        p <- ssc.plot.tsne(sce.Path,gene=c("CXCL13","IL7R","GZMK","ZNF683"),
                   reduced.name="recal.harmony.umap",
                   vector.friendly=T,clamp=c(-0.5,1.5),
                   p.ncol=4,
                   fun.extra=function(p){
                       p + theme_bw(base_size=12) +
                       theme(axis.text=element_text(size=12),
                         plot.title = element_text(hjust=0.5)) +
                       labs(x="UMAP1",y="UMAP2") +
                       coord_fixed(ratio=1, xlim = c(-10, 10), ylim = c(-10, 10), expand = FALSE)
                   },
                   theme.use=theme_void,size=0.55,
                   par.geneOnTSNE=list(scales="fixed",
                               pt.order="random",pt.alpha = 0.5))
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.pdf",out.prefix), width=6.5,height=4.5,useDingbats=FALSE)
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.test.pdf",out.prefix), width=10,height=8,useDingbats=FALSE)
        ggsave(sprintf("%s.geneExample.CD8.vecFri.pdf",out.prefix), width=15,height=3.5,useDingbats=FALSE)

        p <- ssc.plot.tsne(sce.Path,gene=c("IL7R","GZMK","ZNF683","CXCL13"),
                   reduced.name="recal.harmony.umap",
                   vector.friendly=T,clamp=c(-0.5,1.5),
                   p.ncol=2,
                   fun.extra=function(p){
                       p + theme_bw(base_size=12) +
                       theme(axis.text=element_text(size=12),
                         plot.title = element_text(hjust=0.5)) +
                       labs(x="UMAP1",y="UMAP2") +
                       coord_fixed(ratio=1, xlim = c(-10, 10), ylim = c(-6, 6), expand = FALSE)
                   },
                   theme.use=theme_void,size=0.55,
                   par.geneOnTSNE=list(scales="fixed",
                               pt.order="random",pt.alpha = 0.5))
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.pdf",out.prefix), width=6.5,height=4.5,useDingbats=FALSE)
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.test.pdf",out.prefix), width=10,height=8,useDingbats=FALSE)
        ggsave(sprintf("%s.geneExample.CD8.vecFri.v2.pdf",out.prefix), width=6.5,height=4,useDingbats=FALSE)

        p <- ssc.plot.tsne(sce.Path,gene=c("IL7R","GZMK","ZNF683","CXCL13"),
                   reduced.name="recal.harmony.umap",
                   vector.friendly=T,clamp=c(-0.5,1.5),
                   p.ncol=2,
                   fun.extra=function(p){
                       p + theme_void(base_size=12) +
                       theme(
                             #axis.text=element_text(size=12),
                             axis.text=element_blank(),
                         plot.title = element_text(hjust=0.5)) +
                       labs(x="UMAP1",y="UMAP2") +
                       coord_fixed(ratio=1, xlim = c(-10, 10), ylim = c(-6, 6), expand = FALSE)
                   },
                   theme.use=theme_void,size=0.55,
                   par.geneOnTSNE=list(scales="fixed",
                               pt.order="random",pt.alpha = 0.5))
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.pdf",out.prefix), width=6.5,height=4.5,useDingbats=FALSE)
        ##ggsave(sprintf("%s.geneExample.CD8.vecFri.test.pdf",out.prefix), width=10,height=8,useDingbats=FALSE)
        ggsave(sprintf("%s.geneExample.CD8.vecFri.v3.pdf",out.prefix), width=6.5,height=4,useDingbats=FALSE)

    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值