diff small_rna_maps.r @ 30:183bf49fe77c draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/small_rna_maps commit d280e9be7cf96f4938a73ccf5985533109f3328f"
author artbio
date Sat, 05 Oct 2019 18:25:19 -0400
parents fe1a9cfaf5c3
children f2e7ad3058e8
line wrap: on
line diff
--- a/small_rna_maps.r	Fri Oct 04 04:33:53 2019 -0400
+++ b/small_rna_maps.r	Sat Oct 05 18:25:19 2019 -0400
@@ -26,9 +26,12 @@
 args = parse_args(parser)
 
 # data frames implementation
+
 ## first table
 Table = read.delim(args$first_dataframe, header=T, row.names=NULL)
 colnames(Table)[1] <- "Dataset"
+dropcol <- c("Strandness", "z.score") # not used by this Rscript and is dropped for backward compatibility
+Table <- Table[,!(names(Table) %in% dropcol)]
 if (args$first_plot_method == "Counts" | args$first_plot_method == "Size") {
   Table <- within(Table, Counts[Polarity=="R"] <- (Counts[Polarity=="R"]*-1))
 }
@@ -42,6 +45,9 @@
 if (args$first_plot_method == "Counts" | args$first_plot_method == "Size" | args$first_plot_method == "Coverage") {
   i = 1
   for (sample in samples) {
+    # Warning
+    # Here the column is hard coded as the last column (dangerous)
+    # because its name changes with the method
     Table[, length(Table)][Table$Dataset==sample] <- Table[, length(Table)][Table$Dataset==sample]*norm_factors[i]
     i = i + 1
   }
@@ -50,10 +56,13 @@
 per_gene_readmap=lapply(genes, function(x) subset(Table, Chromosome==x))
 per_gene_limit=lapply(genes, function(x) c(1, unique(subset(Table, Chromosome==x)$Chrom_length)) )
 n_genes=length(per_gene_readmap)
+
 # second table
 if (args$extra_plot_method != '') {
   ExtraTable=read.delim(args$extra_dataframe, header=T, row.names=NULL)
   colnames(ExtraTable)[1] <- "Dataset"
+  dropcol <- c("Strandness", "z.score") # not used by this Rscript and is dropped for backward compatibility
+  Table <- Table[,!(names(Table) %in% dropcol)]
   if (args$extra_plot_method == "Counts" | args$extra_plot_method=='Size') {
     ExtraTable <- within(ExtraTable, Counts[Polarity=="R"] <- (Counts[Polarity=="R"]*-1))
   }
@@ -134,10 +143,10 @@
   } else if (method != "Size") {
     p = xyplot(eval(as.name(method))~Coordinate|factor(Dataset, levels=unique(Dataset))+factor(Chromosome, levels=unique(Chromosome)),
                data=df,
-               type='p',
+               type= ifelse(method=='Coverage', 'l', 'p'),
                pch=19,
                cex=0.35,
-               scales= list(relation="free", x=list(rot=0, cex=0.7, tck=0.5), y=list(tick.number=4, rot=90, cex=0.7)),
+               scales= list(relation="free", x=list(rot=0, cex=0.7, axs="i", tck=0.5), y=list(tick.number=4, rot=90, cex=0.7)),
                xlab=NULL, main=NULL, ylab=NULL, ylim=ylimits,
                as.table=T,
                origin = 0,
@@ -146,6 +155,7 @@
                col=c("red","blue"),
                par.strip.text = list(cex=0.7),
                ...)
+    p=combineLimits(p)
   } else {
     p = barchart(Counts~as.factor(Size)|factor(Dataset, levels=unique(Dataset))+Chromosome, data = df, origin = 0,
                  horizontal=FALSE,