@@ -20,6 +20,7 @@ include { imNotification } from '../../nf-core/utils_nfcore_pipeline'
20
20
include { UTILS_NFCORE_PIPELINE } from ' ../../nf-core/utils_nfcore_pipeline'
21
21
include { workflowCitation } from ' ../../nf-core/utils_nfcore_pipeline'
22
22
include { logColours } from ' ../../nf-core/utils_nfcore_pipeline'
23
+ include { calculateStrandedness } from ' ../../nf-core/fastq_qc_trim_filter_setstrandedness'
23
24
24
25
/*
25
26
========================================================================================
@@ -548,63 +549,6 @@ def biotypeInGtf(gtf_file, biotype) {
548
549
}
549
550
}
550
551
551
- //
552
- // Function to determine library type by comparing type counts. Consistent
553
- // between Salmon and RSeQC
554
- //
555
- def calculateStrandedness(forwardFragments, reverseFragments, unstrandedFragments, stranded_threshold= 0.8 , unstranded_threshold= 0.1 ) {
556
- def totalFragments = forwardFragments + reverseFragments + unstrandedFragments
557
- def totalStrandedFragments = forwardFragments + reverseFragments
558
-
559
- def library_strandedness = ' undetermined'
560
- if (totalStrandedFragments > 0 ) {
561
- def forwardProportion = forwardFragments / (totalStrandedFragments as double )
562
- def reverseProportion = reverseFragments / (totalStrandedFragments as double )
563
- def proportionDifference = Math . abs(forwardProportion - reverseProportion)
564
-
565
- if (forwardProportion >= stranded_threshold) {
566
- strandedness = ' forward'
567
- } else if (reverseProportion >= stranded_threshold) {
568
- strandedness = ' reverse'
569
- } else if (proportionDifference <= unstranded_threshold) {
570
- strandedness = ' unstranded'
571
- }
572
- }
573
-
574
- return [
575
- inferred_strandedness : strandedness,
576
- forwardFragments : (forwardFragments / (totalFragments as double )) * 100 ,
577
- reverseFragments : (reverseFragments / (totalFragments as double )) * 100 ,
578
- unstrandedFragments : (unstrandedFragments / (totalFragments as double )) * 100
579
- ]
580
- }
581
-
582
- //
583
- // Function that parses Salmon quant 'lib_format_counts.json' output file to get inferred strandedness
584
- //
585
- def getSalmonInferredStrandedness(json_file, stranded_threshold = 0.8 , unstranded_threshold = 0.1 ) {
586
- // Parse the JSON content of the file
587
- def libCounts = new JsonSlurper (). parseText(json_file. text)
588
-
589
- // Calculate the counts for forward and reverse strand fragments
590
- def forwardKeys = [' SF' , ' ISF' , ' MSF' , ' OSF' ]
591
- def reverseKeys = [' SR' , ' ISR' , ' MSR' , ' OSR' ]
592
-
593
- // Calculate unstranded fragments (IU and U)
594
- // NOTE: this is here for completeness, but actually all fragments have a
595
- // strandedness (even if the overall library does not), so all these values
596
- // will be '0'. See
597
- // https://groups.google.com/g/sailfish-users/c/yxzBDv6NB6I
598
- def unstrandedKeys = [' IU' , ' U' , ' MU' ]
599
-
600
- def forwardFragments = forwardKeys. collect { libCounts[it] ?: 0 }. sum()
601
- def reverseFragments = reverseKeys. collect { libCounts[it] ?: 0 }. sum()
602
- def unstrandedFragments = unstrandedKeys. collect { libCounts[it] ?: 0 }. sum()
603
-
604
- // Use shared calculation function to determine strandedness
605
- return calculateStrandedness(forwardFragments, reverseFragments, unstrandedFragments, stranded_threshold, unstranded_threshold)
606
- }
607
-
608
552
//
609
553
// Function that parses RSeQC infer_experiment output file to get inferred strandedness
610
554
//
0 commit comments