library(Seurat)library(tidyverse)YDL_counts-as.matrix(YDL
assays$RNAdata)YDL_counts-data.frame(gene=rownames(YDL_counts),YDL_counts)YDL_meta-data.frame(Cell=rownames(YDLmeta.data),cell_type=YDLmeta.data$seurat_clusters)#write.table(YDL_counts,"test_counts.txt",row.names=F,sep=\t)#如果是人类数据直接读出文件write.table(YDL_meta,"test_meta.txt",row.names=F,sep=\t,quote=F)head(YDL_meta)head(YDL_counts[1:4,1:4])#可能需要将test_meta.txt的.改为-library(biomaRt)#BasicfunctiontoconvertmousetohumangenenamesconvertMouseGeneList-function(x){require("biomaRt")human=useMart("ensembl",dataset="hsapiens_gene_ensembl")mouse=useMart("ensembl",dataset="mmusculus_gene_ensembl")genesV2=getLDS(attributes=c("mgi_symbol"),filters="mgi_symbol",values=x,mart=mouse,attributesL=c("hgnc_symbol"),martL=human,uniqueRows=T)#humanx-unique(genesV2[,2])#Printthefirst6genesfoundtothescreen#print(head(genes))return(genesV2)}a-convertMouseGeneList(rownames(YDL_counts))head(a)colnames(a)-c("gene","Gene")a-a[!duplicated(a$Gene),]#去除人类基因重复值test_counts-merge(a,YDL_counts,by=c("gene"))test_counts[1:4,1:4]test_count-test_counts[,-1]#删除第一列test_count[1:4,1:4]dim(test_count)dim(YDL_meta)NAME-c("Gene",meta_data$Cell)head(NAME)NAME-c(NAME)head(meta_data$Cell)head(colnames(test_count))colnames(test_count)-NAME#或者更加简单#colnames(test_count)-c("Gene",meta_data$Cell)write.table(test_count,"test_counts.txt",row.names=F,sep=\t,quote=F)#condacreate-ncpdbpython=3.7sourceactivatecpdb#pipinstallcellphonedbcellphonedbmethodstatistical_analysistest_meta.txttest_counts.txt--threads40--counts-data=gene_namecellphonedbplotdot_plotcellphonedbplotheatmap_plottest_meta.txt预览时标签不可点收录于话题#个上一篇下一篇