Created
February 11, 2019 17:14
-
-
Save tobsecret/8f9c072a1943ea9dde287695877060b5 to your computer and use it in GitHub Desktop.
Splitting and samples by chromosome and combining them again in Nextflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chroms = ['chr1', 'chr2', 'chr3'] //let's say we want to try out the first three chromosomes | |
samples = Channel | |
.from (['n1', chroms], | |
['n2', chroms]) | |
//.subscribe {println it} | |
/* | |
[n1, [chr1, chr2, chr3]] | |
[n2, [chr1, chr2, chr3]] | |
*/ | |
//Let's split by sample and chromosome | |
chromosomewise = samples | |
.map {it -> [it[0], it[1].collate(1)]} | |
//.subscribe {println it} | |
/* | |
[n1, [[chr1], [chr2], [chr3]]] | |
[n2, [[chr1], [chr2], [chr3]]] | |
*/ | |
.transpose() | |
//.subscribe {println it} | |
/* | |
[n1, [chr1]] | |
[n1, [chr2]] | |
[n1, [chr3]] | |
[n2, [chr1]] | |
[n2, [chr2]] | |
[n2, [chr3]] | |
*/ | |
//let's combine again by sample | |
samplewise = chromosomewise | |
.groupTuple() | |
//.subscribe {println it} | |
/* | |
[n1, [[chr1], [chr2], [chr3]]] | |
[n2, [[chr1], [chr2], [chr3]]] | |
*/ | |
.map{it -> [it[0], it[1].flatten()]} | |
//.subscribe{println it} | |
/* | |
[n1, [chr1, chr2, chr3]] | |
[n2, [chr1, chr2, chr3]] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment