Skip to content

Commit

Permalink
Merge pull request #3 from rki-mf1/fix_report-plot-segment-names
Browse files Browse the repository at this point in the history
fixed segement names in covergae distribution plot in the html report
  • Loading branch information
MarieLataretu authored Jan 19, 2024
2 parents 92ad537 + 977580c commit f5659f4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions flupipe.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ if (params$run_name != 'none') {
dt.coverage <- as.data.table(ldply(l.infiles.coverage, fread, sep='\t'))
colnames(dt.coverage) <- c("sample","chromosome", "position", "depth")
# rename chromosome column values
dt.coverage$chromosome <- sapply(dt.coverage$chromosome, function(x){
segment <- tail(unlist(strsplit(x,"|",fixed=TRUE)), n=1)
segment <- toString(segment)
return(segment)
})
dt.output <- dt.coverage[, sum(depth > 10), by = sample]
setnames(dt.output, "V1", "covered.bases")
dt.output$genome.length <- dt.coverage[,length(depth), by = sample]$V1
Expand All @@ -281,8 +288,12 @@ dt.bamstats.coverage[,("coverage") := round(.SD,2), .SDcols="coverage"]
dt.bamstats.coverage[,("meandepth") := round(.SD,0), .SDcols="meandepth"]
colnames(dt.bamstats.coverage) <- c("sample","chromosome","reads mapped [%]", "coverage [%]", "mean depth [bp]")
cc <- unlist(strsplit(dt.bamstats.coverage$chromosome,"|",fixed=TRUE))
dt.bamstats.coverage$chromosome <- cc[4*(1:length(dt.bamstats.coverage$chromosome))]
# rename chromosome column values
dt.bamstats.coverage$chromosome <- sapply(dt.bamstats.coverage$chromosome, function(x){
segment <- tail(unlist(strsplit(x,"|",fixed=TRUE)), n=1)
segment <- toString(segment)
return(segment)
})
dt.bamstats.coverage <- reshape(dt.bamstats.coverage, idvar = "sample", timevar = "chromosome", direction = "wide")
Expand Down Expand Up @@ -891,7 +902,6 @@ rm(df.bamstat.data)
rm(dt.bamstats.coverage)
rm(df.output)
rm(df.mapping.table)
rm(cc)
```

### Coverage Distribution
Expand All @@ -903,9 +913,6 @@ The following plots show the read coverage of each sample after mapping. In 100
# dt.coverage <- as.data.table(ldply(l.infiles.coverage, fread, sep='\t'))
# colnames(dt.coverage) <- c("sample","chromosome", "position", "depth")
# rename chromosome column values
dt.coverage$chromosome <- unlist(strsplit(dt.coverage$chromosome,"|",fixed=TRUE))[4*(1:length(dt.coverage$chromosome))]
# reduce amount of data points to be plotted
dt.coverage[, bin:=rep(seq(1, ceiling(length(position) / 100)), each = 100, length.out = length(position)), by = "sample"]
dt.coverage[, mid.bin:=seq(1,length(position)) %% 100 ]
Expand Down

0 comments on commit f5659f4

Please sign in to comment.