Mercurial > repos > artbio > gsc_scran_normalize
comparison scran-normalize.R @ 2:6864acb21714 draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/gsc_scran_normalize commit a14fb3d106b647c4f1dea2c8d3ac7c1e8848b21c
author | artbio |
---|---|
date | Sun, 10 Dec 2023 00:27:45 +0000 |
parents | fb2f1b8b0013 |
children |
comparison
equal
deleted
inserted
replaced
1:fb2f1b8b0013 | 2:6864acb21714 |
---|---|
1 # load packages that are provided in the conda env | |
2 options(show.error.messages = FALSE, | 1 options(show.error.messages = FALSE, |
3 error = function() { | 2 error = function() { |
4 cat(geterrmessage(), file = stderr()) | 3 cat(geterrmessage(), file = stderr()) |
5 q("no", 1, FALSE) | 4 q("no", 1, FALSE) |
6 } | 5 } |
7 ) | 6 ) |
8 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") | 7 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8") |
9 warnings() | 8 warnings() |
10 | 9 |
11 library(optparse) | 10 library(optparse) |
12 library(scran) | 11 library(scran) |
12 library(dynamicTreeCut) | |
13 | 13 |
14 # Arguments | 14 # Arguments |
15 option_list <- list( | 15 option_list <- list( |
16 make_option( | 16 make_option( |
17 c("-d", "--data"), | 17 c("-d", "--data"), |
18 default = NA, | 18 default = NA, |
19 type = "character", | 19 type = "character", |
20 help = "Input file that contains count values to transform" | 20 help = "Input file that contains count values to transform" |
21 ), | |
22 make_option( | |
23 c("-s", "--sep"), | |
24 default = "\t", | |
25 type = "character", | |
26 help = "File separator [default : '%default' ]" | |
27 ), | 21 ), |
28 make_option( | 22 make_option( |
29 "--cluster", | 23 "--cluster", |
30 default = FALSE, | 24 default = FALSE, |
31 action = "store_true", | 25 action = "store_true", |
51 help = "Output name [default : '%default' ]" | 45 help = "Output name [default : '%default' ]" |
52 ) | 46 ) |
53 ) | 47 ) |
54 | 48 |
55 opt <- parse_args(OptionParser(option_list = option_list), | 49 opt <- parse_args(OptionParser(option_list = option_list), |
56 args = commandArgs(trailingOnly = TRUE)) | 50 args = commandArgs(trailingOnly = TRUE)) |
57 | 51 |
58 if (opt$sep == "tab") { | |
59 opt$sep <- "\t" | |
60 } | |
61 | 52 |
62 data <- read.table( | 53 data <- read.table( |
63 opt$data, | 54 opt$data, |
64 check.names = FALSE, | 55 check.names = FALSE, |
65 header = TRUE, | 56 header = TRUE, |
66 row.names = 1, | 57 row.names = 1, |
67 sep = opt$sep | 58 sep = "\t" |
68 ) | 59 ) |
69 | 60 |
70 ## Import data as a SingleCellExperiment object | 61 ## Import data as a SingleCellExperiment object |
71 sce <- SingleCellExperiment(list(counts = as.matrix(data))) | 62 sce <- SingleCellExperiment(list(counts = as.matrix(data))) |
72 | 63 |
79 | 70 |
80 ## Compute sum factors | 71 ## Compute sum factors |
81 sce <- computeSumFactors(sce) | 72 sce <- computeSumFactors(sce) |
82 } | 73 } |
83 | 74 |
84 sce <- normalize(sce) | 75 sce <- logNormCounts(sce) |
85 | 76 |
86 logcounts <- data.frame(genes = rownames(sce), round(logcounts(sce), digits = 5), check.names = FALSE) | 77 logcounts <- data.frame(genes = rownames(sce), round(logcounts(sce), digits = 5), check.names = FALSE) |
87 | 78 |
88 | 79 |
89 write.table( | 80 write.table( |