02

02

02

02

02

02

02

02

02

02

02

02

02

02

02

02

# 二十多万个细胞的单细胞数据集当然是继续顶啊

``````ct <- as.matrix(ct, type="dgCMatrix")
``````

``````# 参考：https://mp.weixin.qq.com/s/tw7lygmGDAbpzMTx57VvFw
data.table = F)
ct[1:4,1:4]
tail(ct[ ,1:4])
rownames(ct)=ct[,1]
ct=ct[,-1]

tmp <- as.matrix(ct, type="dgCMatrix")
sce.all=CreateSeuratObject(counts = tmp )
``````

``````> ct[1:4,1:4]
gene H_ZC-11-292_TAAGTGCAGCAGGTCA H_ZC-11-292_ACAGCCGGTCATACTG
1 RP11-34P13.3 0 0
2 FAM138A 0 0
3 OR4F5 0 0
4 RP11-34P13.7 0 0
> tail(ct[ ,1:4])
gene H_ZC-11-292_TAAGTGCAGCAGGTCA
45063 AC136352.3 0
45064 AC136352.2 0
45065 AC171558.3 0
45066 BX004987.1 0
45067 AC145212.1 0
45068 MAFIP 0
Warning: Data is of class matrix. Coercing to dgCMatrix.
Error: vector memory exhausted (limit reached?)
``````

`````` lapply(0:8, function(i){
# i=1
print(i)
kp= seq(1,ncol(ct)) %in% seq(i*30000 ,(i+1)*30000)
print(table(kp))
tmp= ct[,kp]
tmp=as.matrix( tmp ,
type="dgCMatrix")
save(tmp,file = paste(i,'tmp.Rdata'))
})
``````

`````` library(Seurat)
sceList = lapply(0:8, function(i){
# i=1
print(i)
print(dim(tmp))
sce =CreateSeuratObject(counts = tmp,
#project = i ,
min.cells = 5,
min.features = 300 )
print(sce)
return(sce)
})

sce.all=merge(x=sceList[[1]],
y=sceList[ -1 ] )
names(sce.all@assays\$RNA@layers)
sce.all[["RNA"]]\$counts
# Alternate accessor function with the same result
LayerData(sce.all, assay = "RNA", layer = "counts")
sce.all <- JoinLayers(sce.all)
dim(sce.all[["RNA"]]\$counts )
``````

`````` celltype[celltype\$ClusterID %in% c( 6 ),2]='lymphocytes'
celltype[celltype\$ClusterID %in% c( 3 ),2]='myeloids'
celltype[celltype\$ClusterID %in% c( 1,5 ),2]='endo'
celltype[celltype\$ClusterID %in% c( 8 ),2]='L-endo'
celltype[celltype\$ClusterID %in% c( 9 ),2]='epi'
celltype[celltype\$ClusterID %in% c( 0 ),2]='fibro'
celltype[celltype\$ClusterID %in% c( 4 ),2]='SMC'
celltype[celltype\$ClusterID %in% c( 10 ),2]='Mast'
celltype[celltype\$ClusterID %in% c( 12 ),2]='double'
``````

`````` cg='RYR2 MYH11 DCN VWF CCL21 NRXN1 HAS1 KIT MZB1 PLIN1 C1QC KCNJ8 LEPR CD3E'
gene_list=trimws(strsplit(cg,' ')[[1]])
gene_list
p2 = DotPlot( sce.all.int, features = gene_list,
group.by = 'RNA_snn_res.0.1') +
theme(axis.text.x = element_text(angle = 45, vjust = 0.5, hjust=0.5))
p2
ggsave('heart-0.1.pdf',width=8)
``````

``````
celltype[celltype\$ClusterID %in% c( 7 ),2]='Neuron'
celltype[celltype\$ClusterID %in% c( 2 ),2]='CM'
``````

### 学徒作业

Differential expression analy- sis by pseudobulk and single-cell approaches across disease state revealed a large number of genes significantly upregulated (NPPA, NPPB, ACE2 and KIF13A) and downregulated (MYH6, ADRB2 and CKM) in DCM samples compared to non-diseased donors

02

02