wd="path/to/working/directory"
cd $wd
mkdir -p ${wd}/03_BWAS_uncorrected_allModa_clusterFWER
mkdir -p ${wd}/04_BWAS_5globalPCs_allModa_clusterFWER
mkdir -p ${wd}/05_BWAS_10globalPCs_allModa_clusterFWER
mkdir -p ${wd}/06_BWAS_10specificPCs_allModa_clusterFWER
mkdir -p ${wd}/07_BWAS_MOA_allModa_clusterFWER
mkdir -p ${wd}/08_BWAS_MOA_modaSpeBRM_allModa_clusterFWER
mkdir -p ${wd}/09_BWAS_ICVagesex_allModa_clusterFWER
mkdir -p ${wd}/10_BWAS_MOA_multiORM_QC_allModa_clusterFWER
mkdir -p ${wd}/15_BWAS_MOA_allModa_FE_clusterFWER
for scenario in 03_BWAS_uncorrected_allModa 04_BWAS_5globalPCs_allModa 05_BWAS_10globalPCs_allModa 06_BWAS_10specificPCs_allModa 07_BWAS_MOA_allModa 09_BWAS_ICVagesex_allModa 10_BWAS_MOA_multiORM_QC_allModa 15_BWAS_MOA_allModa_FE
do
mkdir -p $wd/${scenario}_clusterFWER
cd $wd/${scenario}_clusterFWER
${wd}/qsubshcom " module load R/3.5.0 |;
cd "${wd}" |;
for NNN in 0 |;
do |;
if [ ! -f "${wd}"/"${scenario}"_clusterFWER/Results_clusterFWER_NVertices\${NNN}_iter\${TASK_ID}.txt ] |;
then |;
Rscript --no-save 'RR_2.2_BWAS_FWER_wrapper_allModa_Null.R' "${wd}"/"${scenario}" \${TASK_ID} \${NNN} "${wd}"/"${scenario}"_clusterFWER |;
fi |;
done |;
" 1 10G RR_FWER_${scenario}_NNN0 04:00:00 "-array=1-100 "
done
for scenario in 03_BWAS_uncorrected_allModa 04_BWAS_5globalPCs_allModa 05_BWAS_10globalPCs_allModa 06_BWAS_10specificPCs_allModa 07_BWAS_MOA_allModa 09_BWAS_ICVagesex_allModa 10_BWAS_MOA_multiORM_QC_allModa 15_BWAS_MOA_allModa_FE
do
cd $wd/${scenario}_clusterFWER
${wd}/qsubshcom " module load R/3.5.0 |;
cd "${wd}" |;
for NNN in 10 100 1000 |;
do |;
Rscript --no-save 'RR_2.3_BWAS_FWER_wrapper_allModa.R' "${wd}"/"${scenario}" \${TASK_ID} \${NNN} "${wd}"/"${scenario}"_clusterFWER |;
Rscript --no-save 'RR_2.4_BWAS_clusterFWER_wrapper_arrayjob_allModa.R' "${wd}"/"${scenario}" 100 \${NNN} "${wd}"/"${scenario}"_clusterFWER \${TASK_ID} |;
done |;
" 1 10G RR_FWER_${scenario} 48:00:00 "-array=1-100 "
done
for NNN in 0 10 100 1000
do
echo ${NNN}
ls ${wd}/03_BWAS_uncorrected_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/04_BWAS_5globalPCs_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/05_BWAS_10globalPCs_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/06_BWAS_10specificPCs_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/07_BWAS_MOA_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/09_BWAS_ICVagesex_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
ls ${wd}/10_BWAS_MOA_multiORM_QC_allModa_clusterFWER/Summary_BWAS_NVertices${NNN}_* | wc -l
dones
setwd("path/to/working/directory")
for (NNN in c(0, 10, 100, 1000)) {
for (scenario in c("03_BWAS_uncorrected_allModa", "04_BWAS_5globalPCs_allModa",
"05_BWAS_10globalPCs_allModa", "06_BWAS_10specificPCs_allModa",
"07_BWAS_MOA_allModa", "09_BWAS_ICVagesex_allModa", "10_BWAS_MOA_multiORM_QC_allModa",
"15_BWAS_MOA_allModa_FE")) {
= NULL
res for (iter in 1:100) {
if (file.exists(paste0(scenario, "_clusterFWER/Results_clusterFWER_NVertices",
"_iter", iter, ".txt"))) {
NNN, = read.table(paste0(scenario, "_clusterFWER/Results_clusterFWER_NVertices",
aa "_iter", iter, ".txt"), header = T)
NNN, = rbind(res, c(iter, aa))
res else {
} = rbind(res, NA)
res
}write.table(res, paste0(scenario, "_clusterFWER/Results_clusterFWER_NVertices",
".txt"), col.names = T, row.names = F)
NNN,
}
}
}
# Run loop and concatenate results
for (scenario in c("03_BWAS_uncorrected_allModa", "04_BWAS_5globalPCs_allModa",
"05_BWAS_10globalPCs_allModa", "06_BWAS_10specificPCs_allModa",
"07_BWAS_MOA_allModa", "09_BWAS_ICVagesex_allModa", "10_BWAS_MOA_multiORM_QC_allModa",
"15_BWAS_MOA_allModa_FE")) {
for (NNN in c(0, 10, 100, 1000)) {
print(NNN)
if (file.exists(paste0(scenario, "_clusterFWER/Summary_BWAS_NVertices",
"_Niter", 1))) {
NNN, = read.table(paste0(scenario, "_clusterFWER/Summary_BWAS_NVertices",
allbwas "_Niter", 2), header = T)
NNN, else {
} = NA
allbwas
}for (iter in 2:100) {
if (file.exists(paste0(scenario, "_clusterFWER/Summary_BWAS_NVertices",
"_Niter", iter))) {
NNN, = read.table(paste0(scenario, "_clusterFWER/Summary_BWAS_NVertices",
bwas "_Niter", iter), header = T)
NNN, = rbind(allbwas, bwas)
allbwas else {
} = rbind(allbwas, NA)
allbwas
}
}write.table(allbwas, paste0(scenario, "_BWASresults_",
".txt"), col.names = T, row.names = F)
NNN,
} }
wd="path/to/working/directory"
for scenario in 03_BWAS_uncorrected_allModa 09_BWAS_ICVagesex_allModa 04_BWAS_5globalPCs_allModa 05_BWAS_10globalPCs_allModa 06_BWAS_10specificPCs_allModa 07_BWAS_MOA_allModa 10_BWAS_MOA_multiORM_QC_allModa 15_BWAS_MOA_allModa_FE
do
cd $wd/${scenario}_clusterFWER
${wd}/qsubshcom " module load R/3.5.0 |;
cd "${wd}" |;
for NNN in 10 100 1000 |;
do |;
Rscript --no-save 'RR_2.5.3_BWAS_clusterFWER_wrapper_arrayjob_allModa_varySignifThreshold.R' "${wd}"/"${scenario}" 100 \${NNN} "${wd}"/"${scenario}"_clusterFWER \${TASK_ID} |;
done |;
" 1 10G RR_FWER_${scenario}_allSignif_extra 48:00:00 "-array=1-100 "
done
library(matrixStats)
for (NNN in c(10)) {
for (scenario in c("03_BWAS_uncorrected_allModa", "04_BWAS_5globalPCs_allModa",
"05_BWAS_10globalPCs_allModa", "07_BWAS_MOA_allModa",
"06_BWAS_10specificPCs_allModa", "09_BWAS_ICVagesex_allModa",
"10_BWAS_MOA_multiORM_QC_allModa", "15_BWAS_MOA_allModa_FE")) {
= restotTP = NULL
restot
for (iter in 1:100) {
if (file.exists(paste0(wd, scenario, "_clusterFWER/Results_clusterFWER_NVertices",
"_iter", iter, "_allSignifT.txt"))) {
NNN, = read.table(paste0(wd, scenario, "_clusterFWER/Results_clusterFWER_NVertices",
res "_iter", iter, "_allSignifT.txt"))
NNN, = rbind(res[dim(res)[1], ], res[1:(dim(res)[1] -
res 1), ])
colnames(res)
$nbTPclusters = rowSums(res[, c("nbTPclusters_LogJacs",
res"nbTPclusters_area", "nbTPclusters_thickness",
"nbTPclusters_thick")])
$nbTPclusters
res
$NumberFalsePositiveClusters = rowSums(res[,
resc("NumberFalsePositiveClusters_LogJacs", "NumberFalsePositiveClusters_area",
"NumberFalsePositiveClusters_thickness",
"NumberFalsePositiveClusters_thick")])
$NumberFalsePositiveClusters
res
$FDR = res$NumberFalsePositiveClusters/(res$NumberFalsePositiveClusters +
res$nbTPclusters)
res$FDR
res
= cbind(restot, res$NumberFalsePositiveClusters)
restot = cbind(restotTP, res$nbTPclusters/NNN)
restotTP else {
} = cbind(restot, NA)
restot = cbind(restotTP, NA)
restotTP print(paste0(wd, scenario, "_clusterFWER/Results_clusterFWER_NVertices",
"_iter", iter, "_allSignifT.txt"))
NNN,
}
}which(restot > 0, arr.ind = T)] = 1
restot[
= cbind(res$c.signifTList., rowMeans(restot,
restotAll na.rm = T), rowMeans(restotTP, na.rm = T), rowSds(restot,
na.rm = T)/sqrt(100), rowSds(restotTP, na.rm = T)/sqrt(100))
colnames(restotAll) = c("signifT", "clusterFWER", "Power",
"SE_cFWER", "SE_power")
write.table(restotAll, paste0(wd, "power_FWER_allSignifT_",
"_NVertices", NNN, ".txt"), row.names = F)
scenario,
} }
= 0.2
setFWER
= "path/to/working/directory"
wd = "03_BWAS_uncorrected_allModa"
scenario
for (NNN in c(10, 100, 1000)) {
= NULL
comRes for (scenario in c("03_BWAS_uncorrected_allModa", "09_BWAS_ICVagesex_allModa",
"04_BWAS_5globalPCs_allModa", "05_BWAS_10globalPCs_allModa",
"06_BWAS_10specificPCs_allModa", "07_BWAS_MOA_allModa",
"15_BWAS_MOA_allModa_FE", "10_BWAS_MOA_multiORM_QC_allModa")) {
= read.table(paste0("BWAS_summary_fwer/power_FWER_allSignifT_",
res "_NVertices", NNN, ".txt"), header = T)
scenario, if (file.exists(paste0("BWAS_summary_fwer/power_FWER_allSignifT_",
"_NVertices", NNN, "_extra.txt"))) {
scenario, = read.table(paste0("BWAS_summary_fwer/power_FWER_allSignifT_",
res2 "_NVertices", NNN, "_extra.txt"), header = T)
scenario, = rbind(res, res2[-1, ])
res
}if (file.exists(paste0("BWAS_summary_fwer/power_FWER_allSignifT_",
"_NVertices", NNN, "_extra2.txt"))) {
scenario, = read.table(paste0("BWAS_summary_fwer/power_FWER_allSignifT_",
res2 "_NVertices", NNN, "_extra2.txt"),
scenario, header = T)
= rbind(res, res2[-1, ])
res
}= res[which(res$clusterFWER < setFWER), ]
res2 = rbind(comRes, c(scenario, res2[1, ]))
comRes
}print(comRes)
write.table(comRes, paste0("BWAS_summary_fwer/power_FWER_allSignifT_allScenarios_",
"_FWER", setFWER, ".txt"), row.names = F)
NNN,
}
# Visualise results
= read.table("BWAS_summary_fwer/power_FWER_allSignifT_allScenarios_10_FWER0.2.txt",
resTable header = T)
paste0(signif(resTable$Power, 2), " (", signif(resTable$SE_power,
2), ")")
= read.table("BWAS_summary_fwer/power_FWER_allSignifT_allScenarios_100_FWER0.2.txt",
resTable header = T)
paste0(signif(resTable$Power, 2), " (", signif(resTable$SE_power,
2), ")")
= read.table("BWAS_summary_fwer/power_FWER_allSignifT_allScenarios_1000_FWER0.2.txt",
resTable header = T)
paste0(signif(resTable$Power, 2), " (", signif(resTable$SE_power,
2), ")")
setwd("path/to/working/directory")
for (scenario in c("07_BWAS_MOA_allModa_clusterFWER", "10_BWAS_MOA_multiORM_QC_allModa",
"15_BWAS_MOA_allModa_FE")) {
for (NNN in c(0, 10, 100, 1000)) {
= NULL
rsqres for (iter in 1:100) {
= NULL
rsq if (file.exists(paste0(scenario, "/BWAS_NVertices",
"_Niter", iter, ".rsq"))) {
NNN, = read.table(paste0(scenario, "/BWAS_NVertices",
rsq "_Niter", iter, ".rsq"), fill = T, stringsAsFactors = F)
NNN, = rbind(rsqres, c(iter, rsq[5, 2]))
rsqres else {
} = NA
rsq = rbind(rsqres, c(iter, rsq))
rsqres
}
}write.table(rsqres, paste0(scenario, "/BWAS_morphometricity_allModa_N",
".txt"), row.names = F, col.names = F, quote = F)
NNN,
} }
A work by by [Baptiste Couvy-Duchesne] - 13 June 2022