Mercurial > repos > iuc > scater_filter
annotate scater-manual-filter.R @ 3:652923ce664f draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 9961b5acbf9081f10e14bc272406b36854fa2924"
author | iuc |
---|---|
date | Mon, 08 Nov 2021 12:03:34 +0000 |
parents | 7a365ec81b52 |
children |
rev | line source |
---|---|
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
2 # Manually filter SingleCellExperiment with user-defined parameters |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
3 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
4 # Load optparse we need to check inputs |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
5 library(optparse) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
6 library(workflowscriptscommon) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
7 library(LoomExperiment) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
8 library(scater) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
9 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
10 # parse options |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
11 option_list <- list( |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
12 make_option( |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
13 c("-i", "--input-loom"), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
14 action = "store", |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
15 default = NA, |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
16 type = "character", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
17 help = "A SingleCellExperiment object file in Loom format" |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
18 ), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
19 make_option( |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
20 c("-l", "--library-size"), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
21 action = "store", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
22 default = 0, |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
23 type = "numeric", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
24 help = "Minimum library size (mapped reads) to filter cells on" |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
25 ), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
26 make_option( |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
27 c("-m", "--percent-counts-MT"), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
28 action = "store", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
29 default = 100, |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
30 type = "numeric", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
31 help = "Maximum % of mitochondrial genes expressed per cell. Cells that exceed this value will be filtered out" |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
32 ), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
33 make_option( |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
34 c("-f", "--expressed-features"), |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
35 action = "store", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
36 default = 100, |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
37 type = "numeric", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
38 help = "Remove cells that have less than the given number of expressed features" |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
39 ), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
40 make_option( |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
41 c("-d", "--detection-limit"), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
42 action = "store", |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
43 default = 0, |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
44 type = "numeric", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
45 help = "Number of reads mapped to a feature above which it to be deemed as expressed" |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
46 ), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
47 make_option( |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
48 c("-e", "--min-cells-expressed"), |
1
b7ea9f09c02f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 61f3899168453092fd25691cf31871a3a350fd3b"
iuc
parents:
0
diff
changeset
|
49 action = "store", |
b7ea9f09c02f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 61f3899168453092fd25691cf31871a3a350fd3b"
iuc
parents:
0
diff
changeset
|
50 default = 0, |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
51 type = "numeric", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
52 help = "Remove features that occur in less than the given number of cells" |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
53 ), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
54 make_option( |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
55 c("-o", "--output-loom"), |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
56 action = "store", |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
57 default = NA, |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
58 type = "character", |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
59 help = "File name in which to store the SingleCellExperiment object in Loom format" |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
60 ) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
61 ) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
62 |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
63 opt <- wsc_parse_args(option_list, mandatory = c("input_loom", "output_loom")) |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
64 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
65 # Check parameter values |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
66 |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
67 if (! file.exists(opt$input_loom)) { |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
68 stop((paste("File", opt$input_loom, "does not exist"))) |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
69 } |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
70 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
71 # Filter out unexpressed features |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
72 |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
73 sce <- import(opt$input_loom, format = "loom", type = "SingleCellLoomExperiment") |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
74 print(paste("Starting with", ncol(sce), "cells and", nrow(sce), "features.")) |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
75 |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
76 # Filter out low quality cells |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
77 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
78 # Filter low library sizes |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
79 passing_total <- sce$total > opt$library_size |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
80 sce <- sce[, passing_total] |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
81 print(paste("After filtering out low library counts: ", ncol(sce), "cells and", nrow(sce), "features.")) |
1
b7ea9f09c02f
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 61f3899168453092fd25691cf31871a3a350fd3b"
iuc
parents:
0
diff
changeset
|
82 |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
83 # Filter out high MT counts |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
84 passing_mt_counts <- sce$subsets_Mito_percent < opt$percent_counts_MT |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
85 sce <- sce[, passing_mt_counts] |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
86 print(paste("After filtering out high MT gene counts: ", ncol(sce), "cells and", nrow(sce), "features.")) |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
87 |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
88 expr_features <- sce$detected > opt$expressed_features |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
89 sce <- sce[, expr_features] |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
90 print(paste("After filtering out cells with low feature counts: ", ncol(sce), "cells and", nrow(sce), "features.")) |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
91 |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
92 # Create a logical vector of features that are expressed (above detection_limit) |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
93 feature_expressed <- nexprs(sce, detection_limit = opt$detection_limit, byrow = TRUE) > opt$min_cells_expressed |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
94 sce <- sce[feature_expressed, ] |
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
95 print(paste("After filtering out rare features: ", ncol(sce), "cells and", nrow(sce), "features.")) |
0
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
96 |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
97 # Output to a Loom file |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
98 if (file.exists(opt$output_loom)) { |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
99 file.remove(opt$output_loom) |
e6ca62ac65c6
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 5fdcafccb6c645d301db040dfeed693d7b6b4278
iuc
parents:
diff
changeset
|
100 } |
2
7a365ec81b52
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 154318f74839a4481c7c68993c4fb745842c4cce"
iuc
parents:
1
diff
changeset
|
101 export(sce, opt$output_loom, format = "loom") |