-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompileGeneExpressionData.R
More file actions
26 lines (23 loc) · 1.02 KB
/
Copy pathcompileGeneExpressionData.R
File metadata and controls
26 lines (23 loc) · 1.02 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
# Run interactively using salloc --mem=30gb --time=10:00:00
library(limma)
library(rtracklayer)
# Find all directories containing expression files.
expressionDir <- NULL
# Loop through all directories and files on the system, read in the gene counts
# as txt, and compile them.
dirsInLarge <- list.dirs(expressionDir, recursive = FALSE)
geneExpressionLarge <- do.call(cbind, lapply(dirsInLarge, function(directory){
cat(".")
fileIn <- read.table(paste0(directory,
"/star.p2-wasp_md.featureCounts.txt"),
header = TRUE)
expression <- data.frame(v1 = fileIn[,7])
dirSplit <- strsplit(directory, "/")[[1]]
colnames(expression) <- dirSplit[length(dirSplit)]
rownames(expression) <- fileIn[,1]
return(expression)
}))
write.csv(geneExpressionLarge, paste0(expressionDir, "geneExpressionRaw.csv"))
# Use VOOM to transform the data.
geneExpressionLogCPMLarge <- as.matrix(voom(geneExpressionLarge))
write.csv(geneExpressionLogCPMLarge, paste0(expressionDir, "geneExpressionLogCPM.csv"))