Skip to content

Commit 64a6234

Browse files
authored
Merge pull request #84 from bcbio/fix_singleend_lp
Fix single cell read data metrics.
2 parents 669a6dd + 319e272 commit 64a6234

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

inst/templates/rnaseq/00_libs/load_data.R

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
library(tidyverse)
22
library(SummarizedExperiment)
33
library(janitor)
4-
load_metrics <- function(se_object, multiqc_data_dir, gtf_fn, counts){
4+
load_metrics <- function(se=se_object, multiqc=multiqc_data_dir,
5+
gtf=gtf_fn,
6+
counts=counts,
7+
single_end=FALSE){
58

69
# bcbio input
710
if (!is.na(se_object)){
@@ -32,14 +35,21 @@ load_metrics <- function(se_object, multiqc_data_dir, gtf_fn, counts){
3235
summarize(total_reads = sum(fastqc_raw_total_sequences))
3336

3437
# This renames to user-friendly names the metrics columns
38+
if (single_end){
39+
metrics <- metrics %>%
40+
dplyr::filter(!is.na(fastqc_raw_total_sequences))
41+
}else{
42+
metrics <- metrics %>%
43+
dplyr::filter(is.na(fastqc_raw_total_sequences))
44+
}
3545
metrics <- metrics %>%
36-
dplyr::filter(is.na(fastqc_raw_total_sequences)) %>%
3746
remove_empty(which = 'cols') %>%
3847
full_join(total_reads) %>%
3948
mutate(mapped_reads = samtools_reads_mapped) %>%
40-
mutate(exonic_rate = exonic/(star_uniquely_mapped * 2)) %>%
41-
mutate(intronic_rate = intronic/(star_uniquely_mapped * 2)) %>%
42-
mutate(intergenic_rate = intergenic/(star_uniquely_mapped * 2)) %>%
49+
rowwise() %>%
50+
mutate(exonic_rate = exonic/(exonic + intronic + intergenic)) %>%
51+
mutate(intronic_rate = intronic/(exonic + intronic + intergenic)) %>%
52+
mutate(intergenic_rate = intergenic/(exonic + intronic + intergenic)) %>%
4353
mutate(x5_3_bias = qualimap_5_3_bias)
4454

4555
# Sometimes we don't have rRNA due to mismatch annotation, We skip this if is the case

inst/templates/rnaseq/01_quality_assesment/QC.Rmd

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ output:
1717
params:
1818
# Fill this file with the right paths to nfcore output
1919
# Put hg38, mm10, mm39, or other
20-
# params_file: params_qc_nf-core-example.R # example data
21-
params_file: params_qc_nf-core-example.R
20+
# params_file: params_qc-example.R # example data
21+
params_file: params_qc-example.R
2222
genome: hg38
23+
single_end: false
24+
factor_of_interest: sample_type
2325
project_file: ../information.R
2426
functions_file: ../00_libs/load_data.R
25-
factor_of_interest: sample_type
2627
---
2728

2829
Template developed with materials from https://hbctraining.github.io/main/.
@@ -45,6 +46,11 @@ This code is in this ![](https://img.shields.io/badge/status-stable-green) revis
4546
# this is used to color plots, it needs to be part of the metadata
4647
factor_of_interest=params$factor_of_interest
4748
genome=params$genome
49+
<<<<<<< HEAD
50+
singleend=params$singleend
51+
=======
52+
single_end=params$single_end
53+
>>>>>>> c37fcd42e9e4ba276293a9bc591e6298affd14e5
4854
# 2. Set input files in this file
4955
source(params$params_file)
5056
# 3. If you set up this file, project information will be printed below and
@@ -120,7 +126,8 @@ coldata$sample=row.names(coldata)
120126
counts <- load_counts(counts_fn)
121127
counts <- counts[,colnames(counts) %in% coldata$sample]
122128
123-
metrics <- load_metrics(se_object, multiqc_data_dir, gtf_fn, counts) %>%
129+
metrics <- load_metrics(se_object, multiqc_data_dir,
130+
gtf_fn, counts, single_end) %>%
124131
left_join(coldata, by = c('sample')) %>%
125132
as.data.frame()
126133
metrics <- subset(metrics, metrics$sample %in% coldata$sample)

inst/templates/rnaseq/01_quality_assesment/params_qc-example.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Example data
55
coldata_fn='https://raw.githubusercontent.com/bcbio/bcbioR-test-data/devel/rnaseq/nf-core/coldata.csv'
66
counts_fn=url('https://raw.githubusercontent.com/bcbio/bcbioR-test-data/devel/rnaseq/nf-core/star_salmon/salmon.merged.gene_counts.tsv')
7-
se_object=url('https://raw.githubusercontent.com/bcbio/bcbioR-test-data/devel/rnaseq/nf-core/star_salmon/salmon.merged.gene_counts.rds')
87
# This folder is in the output directory inside multiqc folder
98
multiqc_data_dir='https://raw.githubusercontent.com/bcbio/bcbioR-test-data/devel/rnaseq/nf-core/multiqc/star_salmon/multiqc-report-data/'
109
# This file is inside the genome folder in the output directory

0 commit comments

Comments
 (0)