Mercurial > repos > iuc > crosscontamination_barcode_filter
annotate scripts/contamination_plot.R @ 0:582b7bd4ae4c draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
author | iuc |
---|---|
date | Thu, 24 Jan 2019 09:52:58 -0500 |
parents | |
children | 253c9448f524 |
rev | line source |
---|---|
0
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env R |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
2 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
3 require(ggplot2) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
4 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
5 log10histoPlot <- function(columncounts, title=""){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
6 #' Log10 histogram plot |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
7 #' |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
8 #' @param columncounts colSums(input_matrix) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
9 #' @param title Title of plot |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
10 #' @return ggplot grob |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
11 dfer <- data.frame(colcounts=log10(columncounts)) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
12 p1 <- ggplot(dfer, aes(x=colcounts)) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
13 geom_histogram(binwidth = 0.05, color="black",fill="white") + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
14 theme(plot.title = element_text(hjust = 0.5)) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
15 labs(title=title, y="Frequency", x="Library Size (Log10)") |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
16 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
17 return(p1) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
18 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
19 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
20 contaminationPlot <- function(columncounts, title = "", |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
21 indexes.plates, indexes.fullbc, indexes.truebc, |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
22 filtered=FALSE) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
23 { |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
24 #' Plots true and false barcodes |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
25 #' |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
26 #' |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
27 #' @param columncounts colSums(input_matrix) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
28 #' @param title plot title |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
29 #' @param indexes.plates plate line positions |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
30 #' @param indexes.fullbc full batch line positions |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
31 #' @param indexes.truebc true batch line positions |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
32 #' @param filtered specifies whether the positions have been adjusted for true barcodes |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
33 #' @return ggplot grob |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
34 dfer <- data.frame(colcounts=columncounts) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
35 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
36 ## Remove indexes where plates and full barcodes mix |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
37 indexes.fullbc = indexes.fullbc[!(indexes.fullbc %in% indexes.plates)] |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
38 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
39 nit <- length(indexes.truebc) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
40 nif <- length(indexes.fullbc) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
41 nip <- length(indexes.plates) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
42 mval <- max(dfer) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
43 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
44 ## Aesthetics |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
45 min.height <- -200 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
46 tf.spacing.left <- 12 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
47 tf.spacing.right <- 12 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
48 tf.height <- mval - 10000 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
49 bn.height <- mval - 2000 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
50 plate.color <- "grey" |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
51 plate.text.color <- "black" |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
52 plate.text.alpha <- 0.5 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
53 plate.text.size <- 3 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
54 plate.height <- 2* mval / 5 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
55 plate.spacing <- if (filtered) 12 else 24 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
56 plate.height.text <- plate.height - 3000 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
57 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
58 truebcs <- data.frame( |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
59 x=indexes.truebc, y=rep(min.height,nit), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
60 xend=indexes.truebc, yend=rep(mval,nit) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
61 ) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
62 fullbcs <- data.frame( |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
63 x=indexes.fullbc, y=rep(min.height,nif), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
64 xend=indexes.fullbc, yend=rep(mval,nif) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
65 ) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
66 platess <- data.frame( |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
67 x=indexes.plates, y=rep(min.height,nip), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
68 xend=indexes.plates, yend=rep(plate.height,nip) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
69 ) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
70 connecting.bar <- data.frame( |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
71 xsta = min(indexes.plates), ysta = min.height, |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
72 xfin = max(indexes.plates), yfin = min.height |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
73 ) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
74 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
75 p1 <- ggplot() |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
76 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
77 if (!filtered){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
78 p1 <- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
79 geom_segment(data=truebcs, aes(x=x,y=y,xend=xend,yend=yend - 4000), col='grey', lty=2, size=0.2) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
80 geom_segment(data=fullbcs, aes(x=x,y=y,xend=xend,yend=yend), col='blue', lty=1, size=0.4, alpha=0.2) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
81 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
82 else { |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
83 p1 <- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
84 geom_segment(data=truebcs, aes(x=x,y=y,xend=xend,yend=yend), col='blue', lty=1, size=0.4, alpha=0.2) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
85 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
86 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
87 p1 <- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
88 geom_segment(data=platess, aes(x=x,y=y,xend=xend,yend=yend), col=plate.color, lty=1, size=1) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
89 geom_segment(data=connecting.bar, aes(x=xsta,y=ysta,xend=xfin,yend=yfin), col=plate.color, lty=1, size=1) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
90 geom_point( |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
91 data=dfer, aes(x=1:length(rownames(dfer)), y=dfer$colcounts), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
92 pch = 16, cex = 1) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
93 theme(plot.title = element_text(hjust = 0.5), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
94 axis.ticks.x=element_blank(), axis.ticks.y=element_blank(), |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
95 axis.text.x=element_blank()) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
96 labs(title=paste("Contamination Plot\n", title), y="Library Size", x="Barcode Index") + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
97 scale_y_continuous(breaks=seq(0,mval + 10000, 10000)) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
98 scale_x_continuous(breaks=NULL) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
99 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
100 ## Add true/false and batch labels |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
101 res <- lapply(indexes.truebc, function(xval){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
102 batch <- match(xval, indexes.truebc) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
103 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
104 if (!filtered){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
105 p1 <<- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
106 annotate("text", x=xval - tf.spacing.left, size=2, y=tf.height, angle=90, label=" true positives", color = "dark blue", alpha = 0.5) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
107 annotate("text", x=xval + tf.spacing.right, size=2, y=tf.height, angle=-90,label="false positives", color = "black", alpha = 0.5) + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
108 annotate("text", x=xval , size=4, y=bn.height, angle=-90, label=paste("B",batch,sep=""), color = "grey", alpha = 0.8) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
109 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
110 else { |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
111 p1 <<- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
112 annotate("text", x=xval - 48, size=4, y=bn.height, angle=-90, label=paste("B",batch,sep=""), color = "grey", alpha = 0.8) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
113 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
114 }) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
115 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
116 ## Add Plate labels |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
117 res <- lapply(indexes.plates, function(p){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
118 plate.num <- match(p, indexes.plates) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
119 c.label <- paste("Plate", plate.num, sep="") |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
120 b.label <- paste("Plate", plate.num - 1, sep="") |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
121 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
122 # Right label |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
123 if (plate.num < length(indexes.plates)){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
124 p1 <<- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
125 annotate("text", x=p + plate.spacing, size=plate.text.size, y=plate.height.text, angle=-90, |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
126 label=c.label, color = plate.text.color, alpha=plate.text.alpha) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
127 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
128 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
129 # Left label |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
130 if (plate.num > 1){ |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
131 p1 <<- p1 + |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
132 annotate("text", x=p - plate.spacing, size=plate.text.size, y=plate.height.text, angle=90, |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
133 label=b.label, color = plate.text.color, alpha=plate.text.alpha) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
134 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
135 }) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
136 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
137 return(p1) |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
138 } |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
139 |
582b7bd4ae4c
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/crosscontamination_barcode_filter commit 6f73edc667e61fabdab8b24a7ff40942588fee5b
iuc
parents:
diff
changeset
|
140 |