-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep9-lncRNA.R
131 lines (115 loc) · 3.46 KB
/
step9-lncRNA.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
library(SeuratData) #加载seurat数据集
getOption('timeout')
options(timeout=10000)
#InstallData("pbmc3k")
data("pbmc3k")
sce <- pbmc3k.final
table(Idents(sce))
ct=sce@assays$RNA@counts
ct[1:4,1:4]
dim(ct)
library(AnnoProbe)
ids=annoGene( rownames(ct),'SYMBOL','human')
head(ids)
tail(sort(table(ids$biotypes)))
lncGenes= unique(ids[ids$biotypes=='lncRNA',1])
pbGenes = unique(ids[ids$biotypes=='protein_coding',1])
sce=PercentageFeatureSet(sce, features = lncGenes ,
col.name = "percent_lncGenes")
fivenum([email protected]$percent_lncGenes)
C=sce@assays$RNA@counts
dim(C)
C=Matrix::t(Matrix::t(C)/Matrix::colSums(C)) * 100
# 这里的C 这个矩阵,有一点大,可以考虑随抽样
C=C[,sample(1:ncol(C),1000)]
boxplot(as.matrix(Matrix::t(C[lncGenes, ])),
cex = 0.1, las = 1,
xlab = "% total count per cell",
col = (scales::hue_pal())(50)[50:1],
horizontal = TRUE)
#可视化细胞的上述比例情况
feats <- c("nFeature_RNA", "nCount_RNA","percent_lncGenes")
p1=VlnPlot(sce, group.by = "orig.ident",
features = feats, pt.size = 0, ncol = 3) +
NoLegend()
p1
library(ggplot2)
ggsave(filename="Vlnplot1.pdf",plot=p1)
sce = CreateSeuratObject(
counts = ct[pbGenes,]
)
sce <- NormalizeData(sce)
sce <- FindVariableFeatures(sce )
sce <- ScaleData(sce )
sce <- RunPCA(sce, verbose = FALSE)
sce <- FindNeighbors(sce, dims = 1:10, verbose = FALSE)
sce <- FindClusters(sce, resolution = 0.5, verbose = FALSE)
sce <- RunUMAP(sce, dims = 1:10, umap.method = "uwot", metric = "cosine")
table(sce$seurat_clusters)
umap_pbGenes= DimPlot(sce,label = T,repel = T)
sce_pbGenes = sce
sce <- pbmc3k.final
sce = CreateSeuratObject(
counts = ct[lncGenes,]
)
sce <- NormalizeData(sce)
sce <- FindVariableFeatures(sce )
sce <- ScaleData(sce )
sce <- RunPCA(sce, features = VariableFeatures(object = sce),
verbose = FALSE)
sce <- FindNeighbors(sce, dims = 1:10, verbose = FALSE)
sce <- FindClusters(sce, resolution = 0.5, verbose = FALSE)
sce <- RunUMAP(sce, dims = 1:10, umap.method = "uwot", metric = "cosine")
table(sce$seurat_clusters)
sce_lncGenes = sce
umap_lncGenes = DimPlot(sce,label = T,repel = T)
library(patchwork)
umap_lncGenes + umap_pbGenes +
identical(colnames(sce_lncGenes),colnames(sce_pbGenes))
library(gplots)
balloonplot(table(
sce_lncGenes$seurat_clusters,
Idents(pbmc3k.final)
))
balloonplot(table(
sce_pbGenes$seurat_clusters,
Idents(pbmc3k.final)
))
rm(list=ls())
options(stringsAsFactors = F)
library(Seurat)
# BiocManager::install('scRNAseq')
library(scRNAseq)
fluidigm <- ReprocessedFluidigmData()
fluidigm
ct <- floor(assays(fluidigm)$rsem_counts)
ct[1:4,1:4]
dim(ct)
ct=ct[rowSums(ct>1)>10,]
dim(ct)
ct[1:4,1:4]
dim(ct)
library(AnnoProbe)
ids=annoGene( rownames(ct),'SYMBOL','human')
head(ids)
tail(sort(table(ids$biotypes)))
lncGenes= unique(ids[ids$biotypes=='lncRNA',1])
sce = CreateSeuratObject(
counts = ct[lncGenes,]
)
sce <- NormalizeData(sce)
sce <- FindVariableFeatures(sce )
sce <- ScaleData(sce )
sce <- RunPCA(sce, features = VariableFeatures(object = sce),
verbose = FALSE)
sce <- FindNeighbors(sce, dims = 1:10, verbose = FALSE)
sce <- FindClusters(sce, resolution = 0.5, verbose = FALSE)
sce <- RunUMAP(sce, dims = 1:10, umap.method = "uwot", metric = "cosine")
table(sce$seurat_clusters)
sce_lncGenes = sce
umap_lncGenes = DimPlot(sce,label = T,repel = T)
umap_lncGenes
table(
colData(fluidigm)$Biological_Condition,
sce$seurat_clusters
)