Skip to content

Commit

Permalink
renaming pc file for convenience
Browse files Browse the repository at this point in the history
  • Loading branch information
explodecomputer committed Oct 20, 2024
1 parent ee45454 commit 18797df
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions 01-ancestry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ then

section_message "pcs"

if test -f "${genotype_processed_dir}/${bfile_prefix}pc.txt"; then
if test -f "${genotype_processed_dir}/pcs.txt"; then
echo "pcafile already provided"
Rscript resources/genotypes/genetic_outliers.r \
${genotype_processed_dir}/${bfile_prefix}pc.txt \
${genotype_processed_dir}/pcs.txt \
${env_pca_sd} \
${env_n_pcs} \
${genotype_processed_dir}/${bfile_prefix}_genetic_outliers.txt \
Expand All @@ -229,16 +229,16 @@ then
pcs_unrelated
pcs_related
sed -i 1d ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt
cat ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt > ${genotype_processed_dir}/${bfile_prefix}pc.txt
cat ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt > ${genotype_processed_dir}/pcs.txt

else
pcs_unrelated
cp ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/${bfile_prefix}pc.txt
cp ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/pcs.txt
fi

echo "Check PCs e.g. by plotting them"
Rscript resources/genotypes/genetic_outliers.r \
${genotype_processed_dir}/${bfile_prefix}pc.txt \
${genotype_processed_dir}/pcs.txt \
${env_pca_sd} \
${env_n_pcs} \
${genotype_processed_dir}/${bfile_prefix}_genetic_outliers.txt \
Expand Down Expand Up @@ -271,18 +271,18 @@ then
pcs_unrelated
pcs_related
sed -i 1d ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt
cat ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt > ${genotype_processed_dir}/${bfile_prefix}pc.txt
cat ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/scratch/fastpca_pcs_related.txt > ${genotype_processed_dir}/pcs.txt

else
pcs_unrelated
cp ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/${bfile_prefix}pc.txt
cp ${genotype_processed_dir}/scratch/fastpca_pcs_unrelated.txt ${genotype_processed_dir}/pcs.txt

fi

mv ${results_dir}/01/pcaplot.png ${results_dir}/01/pcaplot_round1.png

Rscript resources/genotypes/genetic_outliers.r \
${genotype_processed_dir}/${bfile_prefix}pc.txt \
${genotype_processed_dir}/pcs.txt \
${env_pca_sd} \
${env_n_pcs} \
${genotype_processed_dir}/${bfile_prefix}_genetic_outliers.txt \
Expand Down
3 changes: 2 additions & 1 deletion 03-prs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source config.env

# create results directory
mkdir -p ${results_dir}/03
mkdir -p ${results_dir}/03/ldmats

# log everything from this script to a logfile in the results director
exec &> >(tee ${results_dir}/03/logfile)
Expand Down Expand Up @@ -130,7 +131,7 @@ do
--keep ${genotype_processed_dir}/scratch/ldmats/keeptemp \
--bfile ${genotype_processed_dir}/scratch/tophits/${ph} \
--r2-unphased ref-based bin4 yes-really \
--out ${results_dir}/03/${filename}
--out ${results_dir}/03/ldmats/${filename}

rm -r ${genotype_processed_dir}/scratch/ldmats
fi
Expand Down
2 changes: 1 addition & 1 deletion resources/phenotypes/organise_phenotypes.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ os$phenotypes <- phenotypes

```{r}
gen_covs <- read_gen_covs(
file = file.path(Sys.getenv("genotype_processed_dir"), paste0(Sys.getenv("bfile_prefix"), "pc.txt")),
file = file.path(Sys.getenv("genotype_processed_dir"), paste0("pcs.txt")),
npcs = as.numeric(Sys.getenv("env_n_pcs"))
)
str(gen_covs)
Expand Down
2 changes: 1 addition & 1 deletion test/covariates.r
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ library(here)
library(dotenv)
readRenviron(here("config.env"))

a <- fread(file.path(Sys.getenv("genotype_processed_dir"), paste0(Sys.getenv("bfile_prefix"), "pc.txt")), header=TRUE)
a <- fread(file.path(Sys.getenv("genotype_processed_dir"), paste0("pcs.txt")), header=TRUE)

b <- tibble(FID=a$FID, IID=a$IID, yob = sample(1920:1980, length(FID), replace=TRUE), sex=sample(1:2, length(FID), replace=TRUE), bp_med = rbinom(length(FID), 1, 0.2), choleterol_med= rbinom(length(FID), 1, 0.2), parity=sample(1:5, length(FID), replace=TRUE)

0 comments on commit 18797df

Please sign in to comment.