Mercurial > repos > davidvanzessen > argalaxy_tools
diff report_clonality/RScript.r @ 40:106275b54470 draft
Uploaded
author | davidvanzessen |
---|---|
date | Tue, 30 May 2017 07:26:33 -0400 |
parents | b6936fb52ab9 |
children | a70dbcfa5d8a |
line wrap: on
line diff
--- a/report_clonality/RScript.r Mon Apr 24 09:39:59 2017 -0400 +++ b/report_clonality/RScript.r Tue May 30 07:26:33 2017 -0400 @@ -122,12 +122,17 @@ clonalityFrame = clonalityFrame[!duplicated(clonalityFrame$clonality_clonaltype), ] } +if(nrow(PRODF) == 0){ + stop("No sequences left after filtering") +} + prod.unique.sample.count = data.frame(data.table(PRODF)[, list(Productive_unique=.N), by=c("Sample")]) prod.unique.rep.count = data.frame(data.table(PRODF)[, list(Productive_unique=.N), by=c("Sample", "Replicate")]) unprod.unique.sample.count = data.frame(data.table(UNPROD)[, list(Unproductive_unique=.N), by=c("Sample")]) unprod.unique.rep.count = data.frame(data.table(UNPROD)[, list(Unproductive_unique=.N), by=c("Sample", "Replicate")]) + PRODF$freq = 1 if(any(grepl(pattern="_", x=PRODF$ID))){ #the frequency can be stored in the ID with the pattern ".*_freq_.*" @@ -176,6 +181,7 @@ #create the table on the overview page with the productive/unique counts per sample/replicate #first for sample + sample.count = merge(input.sample.count, prod.sample.count, by="Sample", all.x=T) sample.count$perc_prod = round(sample.count$Productive / sample.count$All * 100) sample.count = merge(sample.count, prod.unique.sample.count, by="Sample", all.x=T) @@ -188,6 +194,16 @@ #then sample/replicate rep.count = merge(input.rep.count, prod.rep.count, by=c("Sample", "Replicate"), all.x=T) + +print(rep.count) + +fltr = is.na(rep.count$Productive) +if(any(fltr)){ + rep.count[fltr,"Productive"] = 0 +} + +print(rep.count) + rep.count$perc_prod = round(rep.count$Productive / rep.count$All * 100) rep.count = merge(rep.count, prod.unique.rep.count, by=c("Sample", "Replicate"), all.x=T) rep.count$perc_prod_un = round(rep.count$Productive_unique / rep.count$All * 100)