-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscClustViz_obj.R
104 lines (82 loc) · 3.47 KB
/
scClustViz_obj.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
library(scmap)
library(celldex)
library(plyr)
library(stats)
library(ggpubr)
library(RColorBrewer)
library(viridis)
library(scales)
library(plyr)
library(stats)
library(ggpubr)
library(RColorBrewer)
library(viridis)
library(scales)
source('~/RatLiver/Codes/Functions.R')
Initialize()
##########################################################################
############## generate scClustViz object for the nuc-seq data ##############
##########################################################################
merged_samples <- readRDS('~/rat_sham_sn_data/standardQC_results/sham_sn_merged_annot_standardQC.rds')
merged_samples = readRDS('~/rat_sham_sn_data/standardQC_results/sham_sn_merged_annot_standardQC.rds')
ncol1 = ncol([email protected])
### perform clustering for a set of resolutions
resolutions = seq(0.4, 2.6, 0.3)
for (res in resolutions){
merged_samples <- FindClusters(merged_samples, resolution = res, verbose = FALSE)
}
Resolution = 0.6
resolutions = Resolution
merged_samples <- FindClusters(merged_samples, resolution = Resolution, verbose = FALSE)
table(merged_samples$SCT_snn_res.0.6)
head([email protected])
your_cluster_results =data.frame([email protected][,colnames([email protected]) %in% paste0('SCT_snn_res.', resolutions)])
colnames(your_cluster_results) = 'res.0.6'
head(your_cluster_results)
### calculating the differentially expressed marker genes
# sCVdata_list <- CalcAllSCV(
# inD=your_scRNAseq_data_object,
# clusterDF=your_cluster_results,
# assayType="SCT", #specify assay slot of data
# DRforClust="harmony",#reduced dimensions for silhouette calc
# exponent=exp(1), #log base of normalized data
# pseudocount=1,
# DRthresh=0.1, #gene filter - minimum detection rate
# testAll=F, #stop testing clusterings when no DE between clusters
# FDRthresh=0.05,
# calcSil=T, #use cluster::silhouette to calc silhouette widths
# calcDEvsRest=T,
# calcDEcombn=T
# )
sCVdata_list <- CalcAllSCV(
inD=merged_samples,
clusterDF=your_cluster_results,
assayType='SCT', #specify assay slot of data
DRforClust="harmony",#reduced dimensions for silhouette calc
#exponent=exp(1), #log base of normalized data
#pseudocount=1,
#DRthresh=0.5, #gene filter - minimum detection rate
testAll=T, #stop testing clusterings when no DE between clusters
#FDRthresh=0.005,
#calcSil=F, #use cluster::silhouette to calc silhouette widths
calcDEvsRest=T,
calcDEcombn= T #
)
saveRDS(sCVdata_list, '~/rat_sham_sn_data/standardQC_results/sham_sn_merged_sCVdata_res.0.6.rds') ### find the results on run1
#saveRDS(sCVdata_list, '~/rat_sham_sn_data/standardQC_results/sham_sn_merged_sCVdata.rds') ### find the results on run1
sham_sn_merged_scCLustViz_object <- paste0("~/rat_sham_sn_data/standardQC_results/sham_sn_merged_standardQC_scCLustViz_object_res.0.6.RData")
#sham_sn_merged_scCLustViz_object <- paste0("~/rat_sham_sn_data/standardQC_results/sham_sn_merged_standardQC_scCLustViz_object.RData")
#save(merged_samples,sCVdata_list,
# file=sham_sn_merged_scCLustViz_object) ## new data scClustViz object
load(sham_sn_merged_scCLustViz_object)
runShiny(
## write the path to the file bellow:
filePath= sham_sn_merged_scCLustViz_object,
outPath="./",
# Save any further analysis performed in the app to the
# working directory rather than library directory.
annotationDB="org.Rn.eg.db",
# This is an optional argument, but will add annotations.
imageFileType="png"
#Set the file format of any saved figures from the app.
)