Skip to content

Commit 2af2796

Browse files
committed
Create RSQ plot from results
1 parent c8487ef commit 2af2796

File tree

6 files changed

+103
-10
lines changed

6 files changed

+103
-10
lines changed

environment.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ channels:
88
dependencies:
99
- plink2
1010
- r=4.1.0
11-
- r-rmarkdown=2.11
12-
- r-ggplot2=3.3.5
13-
- r-dplyr=1.0.7
11+
- r-rmarkdown=2.16
12+
- r-ggplot2=3.3.6
13+
- r-dplyr=1.1.0
1414
- r-dt=0.19
1515
- r-qqman=0.1.8
1616
- r-htmltools=0.5.2
@@ -20,11 +20,12 @@ dependencies:
2020
- r-data.table=1.14.0
2121
- r-r.utils=2.10.1
2222
- r-ggrepel=0.9.1
23-
- pandoc=2.14.2
23+
- pandoc=2.19.2
2424
- cairo=1.16.0
2525
- xorg-libxt=1.2.1
2626
- fonts-anaconda=1
2727
- openjdk=11.0.9
2828
- unzip=6.0
2929
- bioconductor-ramwas=1.16.0
3030
- bedtools=2.30.0
31+
- csvtk=0.26.0

files/rsq-report.Rmd

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: "Imputation Quality Report"
3+
output:
4+
rmdformats::robobook:
5+
self_contained: true
6+
thumbnails: false
7+
lightbox: true
8+
gallery: false
9+
highlight: tango
10+
params:
11+
input: ""
12+
name: ""
13+
population: ""
14+
version: ""
15+
date: ""
16+
service: ""
17+
---
18+
19+
```{r setup, echo=FALSE, include=FALSE}
20+
21+
library(ggplot2)
22+
library(dplyr)
23+
```
24+
25+
## Parameters
26+
27+
| Parameter | Value |
28+
|------------------|-----------------------------|
29+
| Job | `r params$name` |
30+
| Pipeline Version | `r params$version` |
31+
| Date | `r params$date` |
32+
33+
## RSQ Plot
34+
```{r echo=FALSE}
35+
dataset = read.csv(params$input, row.names=NULL, sep = '\t')
36+
dataset_weighted = dataset %>%
37+
group_by (
38+
X.Bin.Aggregated.by.MAF
39+
) %>%
40+
summarise (
41+
mean_MAF = mean(Average.MAF),
42+
variants_sum = sum(X.Variants),
43+
weighted_R2 = weighted.mean(Imputation.R2,X.Variants)
44+
)
45+
46+
ggplot() + geom_line(data = dataset_weighted, mapping = aes(x = mean_MAF, y= weighted_R2)) + scale_x_log10() + expand_limits(x = 0, y = 0)
47+
48+
```
49+
50+
<small>
51+
This report has been created with **`r params$service`**.
52+
</small>

modules/local/calculate_rsq.nf

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
process CALCULATE_RSQ {
22

3-
publishDir "${params.pubDir}/aggRSquare", mode: 'copy', pattern: '*aggRSquare'
3+
publishDir "${params.pubDir}/rsq", mode: 'copy', pattern: '*aggRSquare'
44

55
input:
66
tuple val(chr), path(dosage_data), path(sequence_data)
@@ -11,5 +11,6 @@ process CALCULATE_RSQ {
1111

1212
"""
1313
aggRSquare -v ${sequence_data} -i ${dosage_data} -o ${sequence_data.baseName} --d
14+
sed -i '/^##/d' ${sequence_data.baseName}.aggRSquare
1415
"""
1516
}

modules/local/plot_rsq.nf

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
process PLOT_RSQ {
2+
3+
publishDir "${params.pubDir}/rsq", mode: 'copy', pattern: '*html'
4+
5+
input:
6+
path(agg_rsq)
7+
path(rsq_report)
8+
9+
output:
10+
path("*.html")
11+
12+
script:
13+
"""
14+
csvtk concat -C '\$' -t -T $agg_rsq -o combined.txt
15+
16+
Rscript -e "require( 'rmarkdown' ); render('${rsq_report}',
17+
params = list(
18+
input = 'combined.txt',
19+
name = '${params.project}',
20+
version = paste('${workflow.manifest.name}', '(v${workflow.manifest.version})'),
21+
date = '${params.project_date}'
22+
),
23+
intermediates_dir='\$PWD',
24+
knit_root_dir='\$PWD',
25+
output_file='\$PWD/rsq-report.html'
26+
)"
27+
"""
28+
29+
}

nextflow.config

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
manifest {
22
name = 'microarray-eval-nf'
3-
version = '0.0.2'
4-
description = 'Nextflow pipeline to eval microarray chips'
3+
version = '0.1.0'
4+
description = 'Nextflow pipeline to evaluate imputation quality'
55
author = 'Sebastian Schönherr, Lukas Forer, Martin Eberle'
6-
homePage = 'https://github.com/seppinho/exome-cnv-nf'
6+
homePage = 'https://github.com/genepi/microarray-eval-nf'
77
mainScript = 'main.nf'
88
nextflowVersion = '!>=21.04.0'
99
}
1010

1111
// Global default params, used in configs
1212
params {
1313

14+
project_date = "`date`"
1415
//Required inputs
15-
wf = null
16+
17+
workflow_name = null
1618
project = null
1719
sequence_data = null
1820
dosage_data = null

workflows/rsq.nf

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
include { LIFT_OVER } from '../modules/local/lift_over'
22
include { CALCULATE_RSQ } from '../modules/local/calculate_rsq'
3+
include { PLOT_RSQ } from '../modules/local/plot_rsq'
34

45
workflow RSQ {
56

@@ -25,7 +26,14 @@ workflow RSQ {
2526
r2_input_data_lifted = r2_input_data_combined
2627
}
2728

28-
CALCULATE_RSQ ( r2_input_data_lifted )
29+
CALCULATE_RSQ (
30+
r2_input_data_lifted
31+
)
32+
33+
PLOT_RSQ (
34+
CALCULATE_RSQ.out.agg_rsquare.collect(),
35+
file("$baseDir/files/rsq-report.Rmd", checkIfExists: true)
36+
)
2937

3038
}
3139

0 commit comments

Comments
 (0)