-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterferonScore.R
More file actions
executable file
·51 lines (39 loc) · 2.04 KB
/
InterferonScore.R
File metadata and controls
executable file
·51 lines (39 loc) · 2.04 KB
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
##### You will need singscore installed use: if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager"); BiocManager::install("singscore")
##### You will need Genome wide annotation of Human installed use: if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager"); BiocManager::install("org.Hs.eg.db")
##### You will need openxlsx installed use: install.packages('openxlsx')
##### Pvalues requires BiocParallel use: if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager"); BiocManager::install("BiocParallel")
library('singscore')
library("org.Hs.eg.db")
library('openxlsx')
##### Input expression matrix file path, expression matrix should be a .xlsx file with gene identifiers in column 1
Exp<-""
#### What sheet is the expression matrix on?
Sheet=1
##### Input gene list file path. Should be a text file with 1 gene per column, no header
GeneList<-""
##### Out file name, will be created in current working directory unless full path is given, please include the '.xlsx' ending
OutFile<-''
##### Do you have a symbols column? TRUE or FALSE in your expression matrix?
GeneSymbols=FALSE
##### Do you want P-values? May take longer to run. TRUE or FALSE
Pvalues=FALSE
#### Number of Bootstraps for Permutated pvalues
Boots=500
Exp<-read.xlsx(Exp,sheet=Sheet,rowNames=TRUE)
Genes<-as.data.frame(read.table(GeneList,stringsAsFactors=FALSE))
Map<-unique(as.character(mapIds(org.Hs.eg.db,Genes$V1,'ENTREZID','SYMBOL')))
if(isTRUE(GeneSymbols)){
Exp<-Exp[,-c(1)]
} else {
}
Rank<-rankGenes(Exp)
Scored<-simpleScore(Rank,upSet=Map)
if (isTRUE(Pvalues)){
ncores <- parallel::detectCores() - 2
permuteResult <- generateNull(upSet=Map, rankData = Rank[,1:ncol(Rank)], centerScore=TRUE, knownDirection=TRUE, B=Boots, ncores=ncores, seed=109327051,useBPPARAM=NULL)
pvals=getPvals(permuteResult,Scored[1:ncol(Scored)])
Scored<-cbind(Scored,pvals)
write.xlsx(Scored,OutFile,row.names=TRUE)
} else {
write.xlsx(Scored,OutFile,row.names=TRUE)
}