Repository 'scater_create_qcmetric_ready_sce'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/scater_create_qcmetric_ready_sce

Changeset 1:fd808de478b1 (2019-09-03)
Previous changeset 0:2d455a7e8a3d (2019-07-18) Next changeset 2:b834074a9aff (2021-09-09)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/scater commit 61f3899168453092fd25691cf31871a3a350fd3b"
modified:
README.md
macros.xml
scater-manual-filter.R
scater-plot-dist-scatter.R
added:
environment.yml
scater-plot-tsne.R
test-data/scater_reads_genes_dist_log.pdf
test-data/scater_tsne_plot.pdf
b
diff -r 2d455a7e8a3d -r fd808de478b1 README.md
--- a/README.md Thu Jul 18 11:14:06 2019 -0400
+++ b/README.md Tue Sep 03 14:26:31 2019 -0400
[
@@ -20,6 +20,13 @@
 
 ## Command-line usage
 
+The scripts require the installation of scater and few other R/BioConductor packages. An easy way to install them is to create a [conda](https://conda.io/) environment using the `environment.yml` file distributed together with these wrappers:
+
+```
+conda env create -f environment.yml
+conda activate scater
+```
+
 For help with any of the following scripts, run:
  `<script-name> --help`
 
b
diff -r 2d455a7e8a3d -r fd808de478b1 environment.yml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/environment.yml Tue Sep 03 14:26:31 2019 -0400
b
@@ -0,0 +1,14 @@
+name: scater
+channels:
+  - conda-forge
+  - bioconda
+  - defaults
+dependencies:
+  - bioconductor-loomexperiment=1.2.0
+  - bioconductor-scater=1.12.2
+  - r-ggpubr=0.2.2
+  - r-mvoutlier=2.0.9
+  - r-optparse=1.6.2
+  - r-rtsne=0.15
+  - r-scales=1.0.0
+  - r-workflowscriptscommon=0.0.4
b
diff -r 2d455a7e8a3d -r fd808de478b1 macros.xml
--- a/macros.xml Thu Jul 18 11:14:06 2019 -0400
+++ b/macros.xml Tue Sep 03 14:26:31 2019 -0400
b
@@ -1,11 +1,11 @@
 <macros>
-    <token name="@TOOL_VERSION@">1.10.1</token>
+    <token name="@TOOL_VERSION@">1.12.2</token>
     <xml name="requirements">
         <requirements>
             <requirement type="package" version="@TOOL_VERSION@">bioconductor-scater</requirement>
             <requirement type="package" version="1.6.2">r-optparse</requirement>
             <requirement type="package" version="0.0.4">r-workflowscriptscommon</requirement>
-            <requirement type="package" version="1.0.4">bioconductor-loomexperiment</requirement>
+            <requirement type="package" version="1.2.0">bioconductor-loomexperiment</requirement>
             <yield />
         </requirements>
     </xml>
b
diff -r 2d455a7e8a3d -r fd808de478b1 scater-manual-filter.R
--- a/scater-manual-filter.R Thu Jul 18 11:14:06 2019 -0400
+++ b/scater-manual-filter.R Tue Sep 03 14:26:31 2019 -0400
[
@@ -31,6 +31,13 @@
     help = "Minimum library size (mapped reads) to filter cells on"
   ),
   make_option(
+    c("-e", "--expressed-genes"),
+    action = "store",
+    default = 0,
+    type = 'numeric',
+    help = "Minimum number of expressed genes to filter cells on"
+  ),
+  make_option(
     c("-m", "--percent-counts-MT"),
     action = "store",
     default = 100,
@@ -71,6 +78,14 @@
 
 print(paste("After filtering out low library counts: ", ncol(scle), "cells and", nrow(scle), "features."))
 
+
+# Filter low expressed genes
+to_keep <- scle$total_features_by_counts > opt$expressed_genes
+scle <- scle[, to_keep]
+
+print(paste("After filtering out low expressed: ", ncol(scle), "cells and", nrow(scle), "features."))
+
+
 # Filter out high MT counts
 to_keep <- scle$pct_counts_MT < opt$percent_counts_MT
 scle <- scle[, to_keep]
b
diff -r 2d455a7e8a3d -r fd808de478b1 scater-plot-dist-scatter.R
--- a/scater-plot-dist-scatter.R Thu Jul 18 11:14:06 2019 -0400
+++ b/scater-plot-dist-scatter.R Tue Sep 03 14:26:31 2019 -0400
b
@@ -9,6 +9,7 @@
 library(LoomExperiment)
 library(scater)
 library(ggpubr)
+library(scales)
 
 # parse options
 
@@ -26,10 +27,17 @@
     default = NA,
     type = 'character',
     help = "Path of the PDF output file to save plot to."
+  ),
+  make_option(
+    c("-l", "--log-scale"),
+    action="store_true",
+    default=FALSE,
+    type = 'logical',
+    help = "Plot on log scale (recommended for large datasets)."
   )
 )
 
-opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file'))
+opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file', 'log_scale'))
 
 # Check parameter values
 
@@ -51,12 +59,21 @@
 read_bins <- max(total_counts / 1e6) / 20
 feat_bins <- max(total_features) / 20
 
-#make the plots
+# Make the plots
 plot <- ggplot(cf_dm, aes(x=total_counts / 1e6, y=total_features)) + geom_point(shape=1) + geom_smooth() + xlab("Read count (millions)") +
    ylab("Feature count") + ggtitle("Scatterplot of reads vs features")
 plot1 <- qplot(total_counts / 1e6, geom="histogram", binwidth = read_bins, ylab="Number of cells", xlab = "Read counts (millions)", fill=I("darkseagreen3")) + ggtitle("Read counts per cell")
 plot2 <- qplot(total_features, geom="histogram", binwidth = feat_bins, ylab="Number of cells", xlab = "Feature counts", fill=I("darkseagreen3")) + ggtitle("Feature counts per cell")
 plot3 <- plotColData(scle, y="pct_counts_MT", x="total_features_by_counts") + ggtitle("% MT genes") + geom_point(shape=1) + theme(text = element_text(size=15)) + theme(plot.title = element_text(size=15))
 
-final_plot <- ggarrange(plot1, plot2, plot, plot3, ncol=2, nrow=2)
-ggsave(opt$output_plot_file, final_plot, device="pdf")
+if (! opt$log_scale){
+  final_plot <- ggarrange(plot1, plot2, plot, plot3, ncol=2, nrow=2)
+  ggsave(opt$output_plot_file, final_plot, device="pdf")
+} else {
+  plot_log_both <- plot + scale_x_continuous(trans = 'log10') + scale_y_continuous(trans = 'log10')
+  plot1_log <- plot1 + scale_y_continuous(trans = 'log10')
+  plot2_log <- plot2 + scale_y_continuous(trans = 'log10')
+  plot3_log <- plot3 + scale_y_log10(labels=number)
+  final_plot_log <- ggarrange(plot1_log, plot2_log, plot_log_both, plot3_log, ncol=2, nrow=2)
+  ggsave(opt$output_plot_file, final_plot_log, device="pdf")
+}
b
diff -r 2d455a7e8a3d -r fd808de478b1 scater-plot-tsne.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/scater-plot-tsne.R Tue Sep 03 14:26:31 2019 -0400
b
@@ -0,0 +1,69 @@
+#!/usr/bin/env Rscript
+
+# Creates a t-SNE plot of a normalised SingleCellExperiment object.
+
+# Load optparse we need to check inputs
+
+library(optparse)
+library(workflowscriptscommon)
+library(LoomExperiment)
+library(scater)
+library(Rtsne)
+
+# parse options
+
+option_list = list(
+  make_option(
+    c("-i", "--input-loom"),
+    action = "store",
+    default = NA,
+    type = 'character',
+    help = "A SingleCellExperiment object file in Loom format."
+  ),
+  make_option(
+    c("-c", "--colour-by"),
+    action = "store",
+    default = NULL,
+    type = 'character',
+    help = "Feature (from annotation file) to colour t-SNE plot points by. The values represented in this options should be categorical"
+  ),
+  make_option(
+    c("-s", "--size-by"),
+    action = "store",
+    default = NULL,
+    type = 'character',
+    help = "Feature (from annotation file) to size t-SNE plot points by. The values represented in this options should be numerical and not categorical"
+  ),
+  make_option(
+    c("-p", "--shape-by"),
+    action = "store",
+    default = NULL,
+    type = 'character',
+    help = "Feature (from annotation file) to shape t-SNE plot points by. The values represented in this options should be categorical"
+  ),
+  make_option(
+    c("-o", "--output-plot-file"),
+    action = "store",
+    default = NA,
+    type = 'character',
+    help = "Path of the PDF output file to save plot to."
+  )
+)
+
+opt <- wsc_parse_args(option_list, mandatory = c('input_loom', 'output_plot_file'))
+# Check parameter values
+
+if ( ! file.exists(opt$input_loom)){
+  stop((paste('File', opt$input_loom, 'does not exist')))
+}
+
+
+# Input from Loom format
+
+scle <- import(opt$input_loom, format='loom', type='SingleCellLoomExperiment')
+scle <- normalize(scle, exprs_values = 1)
+scle <- runTSNE(scle, perplexity=10)
+plot <- plotTSNE(scle, colour_by = opt$colour_by, size_by = opt$size_by, shape_by = opt$shape_by)
+
+
+ggsave(opt$output_plot_file, plot, device="pdf")
b
diff -r 2d455a7e8a3d -r fd808de478b1 test-data/scater_reads_genes_dist_log.pdf
b
Binary file test-data/scater_reads_genes_dist_log.pdf has changed
b
diff -r 2d455a7e8a3d -r fd808de478b1 test-data/scater_tsne_plot.pdf
b
Binary file test-data/scater_tsne_plot.pdf has changed