-
Notifications
You must be signed in to change notification settings - Fork 1
/
cleanCountOverlap
executable file
·47 lines (36 loc) · 1.12 KB
/
cleanCountOverlap
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
#! /usr/bin/env Rscript
#
# Vivek Rai
# (c) Parker Lab
#
# November 20, 2018
#
args <- commandArgs(trailingOnly = TRUE)
'cleanCountOverlap v1.1
Cleans output of featureCounts tool. Do not use on processed output!
a. Strip file endings and paths
b. Save to a RDS file for fast loading in R
Usage:
cleanCountOverlap <file>... [--transpose]
Options:
-h --help Show this screen.
--transpose Transpose the input matrix (bams x features)
' -> doc
arguments <- docopt::docopt(doc, version = '1.1')
for (i in 1:length(args)) {
message(paste("Reading argument(s)..", args[i]))
df <- data.table::fread(args[i], header = T, skip = 1, drop = c(1, 5), showProgress = T)
message("Cleaning colnames..")
colnames(df) <- sapply(colnames(df),
function(x) tools::file_path_sans_ext(basename(x))
)
message("Adjusting GTF coordinates to BED..")
df[['Start']] <- df[['Start']] - 1
message("Saving RDS file (use readRDS)..")
if (arguments$transpose) {
message("Taking transpose..")
df <- t(df)
}
saveRDS(df, paste0(tools::file_path_sans_ext(args[i]), '.rds'))
}