Update ATAC-seq pipeline - #322
Conversation
sof202
left a comment
There was a problem hiding this comment.
Some nice changes here Marina. Some of the explanations in the Rmarkdown have much more clarity and succinctness than before.
This was pretty hard to review however. All I see on my end is one lump sum of all of your changes from the last couple of months. It would be easier to see your intentions behind changes if each change came as a different commit. As such I must assume I have missed a lot of minor details here. For example, you might remove a function somehwere, but I have no idea why it is has been removed (perhaps it has been replaced, moved or simply isn't needed anymore, I have no way of knowing).
I trust that you and Philippa have already been using these scripts and so they should be functional.
| metadata<-read.table(sampleSheet, header = TRUE, sep = ',', stringsAsFactors = FALSE) | ||
|
|
||
| samplesPassed <- read.csv(file.path(paste0(metaDir,"/passAllStatus.csv")), sep = ",",stringsAsFactors = FALSE) | ||
| samplesPassed <- samplesPassed[samplesPassed$QCS1 == TRUE & samplesPassed$QCS2 == TRUE,] | ||
| qcStats <- read.csv(file.path(paste0(metaDir,"/samplesGroupAnalysisQC1.csv")), sep = ",",stringsAsFactors = FALSE) | ||
|
|
||
| if(file.exists(paste0(metaDir,"/leaveOutSamples.txt"))){ | ||
| loSamples <- read.table(file.path(paste0(metaDir,"/leaveOutSamples.txt")))[,1] | ||
| samplesStatus <- samplesPassed[!samplesPassed$sampleID %in% loSamples,] | ||
| pheno <- metadata[metadata$sampleID %in% samplesStatus$sampleID,] | ||
| samplesStatus <- samplesStatus[samplesStatus$sampleID %in% pheno$sampleID,] | ||
| qcStats <- qcStats[qcStats$Sample %in% samplesStatus$sampleID,] | ||
| }else{ | ||
| pheno <- metadata[metadata$sampleID %in% samplesPassed$sampleID,] | ||
| qcStats <- qcStats[qcStats$Sample %in% samplesPassed$sampleID,] | ||
|
|
||
| } | ||
|
|
||
| df_ordered <- pheno[order(pheno$fraction), ] | ||
| samplesPassed <- read.csv(file.path(qc12stats), sep = ",",stringsAsFactors = FALSE) | ||
| samples <- read.csv(file.path(groupAnalysisSamples), sep = ",",stringsAsFactors = FALSE) | ||
| samplesPassed <- samplesPassed[samplesPassed$PASSALL == TRUE,] | ||
| qcStats <- read.table(qc1stats, header = TRUE, sep = ',', stringsAsFactors = FALSE) |
There was a problem hiding this comment.
Can I ask why all of our scrips state stringsAsFactors = FALSE. Do we ever have this as TRUE anywhere at all? The default behaviour is this being set to FALSE. The separator being set here is also not really required as it is also the default, but I'm more ok with this as it make it more obvious what the expected format is.
| } | ||
|
|
||
| df_ordered <- pheno[order(pheno$fraction), ] | ||
| samplesPassed <- read.csv(file.path(qc12stats), sep = ",",stringsAsFactors = FALSE) |
There was a problem hiding this comment.
Is file.path() required here? I assume that qc12stats is just some string, in which case this function call is not doing anything. If it qc12stats is a vector of strings, then nevermind.
| samplesPassed <- samplesPassed[samplesPassed$PASSALL == TRUE,] | ||
| qcStats <- read.table(qc1stats, header = TRUE, sep = ',', stringsAsFactors = FALSE) | ||
| metadata$sequencingBatch <- as.factor(metadata$sequencingBatch) | ||
| metadata<- droplevels(metadata) |
There was a problem hiding this comment.
What am I missing here? Is this actually doing anything? This call will remove any levels in a factor vector that has no representation in the vector:
a <- factor(c(1,1,2,2,3))
a[5] <- 2
# 3 is still a level despite not appearing in a
a <- droplevels(a)
# 3 is removed as a levelBut here, the only factor column is the sequencingBatch column. The levels have just been generated in the previous line and so all levels appear in the column still. This therefore does nothing right?
| @@ -81,8 +67,6 @@ colors <- brewer.pal(3, "Set2") | |||
| ## Load counts in peaks files and match to pheno samples data | |||
| tpm.scores<-tpm.scores[,which(tpm.pca > 0.01)] | ||
| percentVar = round(100 * (tpm.pca) ) | ||
| results <- list(tpm.scores[,c(1:5)], percentVar) | ||
| results <- list(tpm.scores[,c(1:4)], percentVar) |
There was a problem hiding this comment.
Any particular reason we are now taking 4 instead of 5 principle components? If this is something that would end up being variable, it might be a good idea to add it as a function parameter so the caller can decide how many to pick.
| ## - <cell-group>.filt.broadPeak.bed" in 4_calledpeaks folder || | ||
| ## || | ||
| ## REQUIRES: || | ||
| ## - R version > 4.3 || |
There was a problem hiding this comment.
Here we now require a version of R greater than 4.3. I presume you meant R >= 4.3
| samples <- names(listSamples) | ||
| for(i in 1:length(listSamples)) { | ||
| df <-data.frame(listSamples[i]) | ||
| df <-data.frame(listSamples[[i]]) |
There was a problem hiding this comment.
This is good, I encourage indexing like this.
| multiqc . -f -o ${FASTQCDIR}/multiqc | ||
| multiqc ${FASTQCDIR}/*_fastqc.zip -f -o ${FASTQCDIR}/multiqc | ||
| rm -f *.html | ||
|
|
||
| cd ${ALIGNED_DIR} | ||
| multiqc . -f -o ${ALIGNED_DIR}/multiqc | ||
| multiqc ${ALIGNED_DIR}/*.bowtie.log -f -o ${ALIGNED_DIR}/multiqc | ||
|
|
||
| cd ${TRIM_DIR}/qc | ||
| multiqc . -f -o ${TRIM_DIR}/multiqc | ||
| multiqc ${TRIM_DIR}/qc/*_trimmed_fastqc.zip -f -o ${TRIM_DIR}/multiqc |
| if [[ ! $2 =~ "FRAGSIZE" ]] && [[ ! $2 =~ "PEAKS" ]] && [[ ! $2 =~ "COUNTS" ]] && [[ ! $2 == '' ]]; | ||
| if [[ ! $2 =~ "PEAKS" ]] && [[ ! $2 =~ "COUNTS" ]] && [[ ! $2 == 'FILT' ]] && [[ ! $2 == 'CTCHECK' ]] && [[ ! $2 == 'DIFFCOUNTS' ]] && [[ ! $2 == ' ' ]]; | ||
| then | ||
| { echo "Unknown step specified. Please use FRAGSIZE, PEAKS, COUNTS or some combination of this as a single string (i.e. FASTQC,TRIM)" ; exit 1; } |
There was a problem hiding this comment.
This is echo has gone stale (COUNTS no longer exists and is replaced by 3 new steps".
If you still want to have combinations of steps you will need to continue using =~ pattern matching instead of == equality.
|
|
||
| ## mark duplicates only | ||
| picard MarkDuplicates --INPUT ${ALIGNED_DIR}/${sampleName}_sorted_name.bam --OUTPUT ${ALIGNED_DIR}/baseRecalibrate/${sampleName}_dedup.bam --METRICS_FILE ${ALIGNED_DIR}/baseRecalibrate/${sampleName}_metrics.txt --TMP_DIR ${TMPDIR} | ||
| picard MarkDuplicates --INPUT ${ALIGNED_DIR}/${sampleName}_sorted_name.bam \ |
There was a problem hiding this comment.
Am I correct in assuming that picard creates ${ALIGNED_DIR}/baseRecalibrate? Or is this now created elsewhere (hence the mkdir command being removed on line 37)
Description
This pull request will update the ATAC-seq pipeline with the latest working scripts. Documentation still needs to be fully updated. The scripts of this update still need to be reviewed.
Issue ticket number
This pull request is to address issue: #number.
Type of pull request
Checklist