Skip to content

Commit

Permalink
update: format .sh scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacquin committed Apr 17, 2024
1 parent b45080f commit 70f1a29
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion clean_scans.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ rm -r genome_scan_chromo_num*
rm -r results_genome_scan
rm data_parameters/kernel_index.txt
rm data_parameters/nb_snp_hap.txt
rm data_parameters/nb_chromosomes.txt
rm data_parameters/nb_chromosomes.txt
rm data_parameters/trait_name.txt
rm data_parameters/signif_level.txt
36 changes: 18 additions & 18 deletions get_results_scans.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ if [ ! -d results_genome_scan ]; then
fi
cd data_parameters/

nb_chromosomes=$(cat "nb_chromosomes.txt")
nb_snp_hap=$(cat "nb_snp_hap.txt")
nb_chromosomes=$(cat "nb_chromosomes.txt")
nb_snp_hap=$(cat "nb_snp_hap.txt")
kernel_index=$(cat "kernel_index.txt")

modify_signif_level=false # true or false (note lower case)
Expand All @@ -33,7 +33,7 @@ cp physical_map.txt ../results_genome_scan
cp phased_genotypes.txt ../results_genome_scan
cp kernel_index.txt ../results_genome_scan
cp signif_level.txt ../results_genome_scan

cd ../programs/
cp get_results_scans.R ../results_genome_scan
cp plot_nb_hap_scans.R ../results_genome_scan
Expand Down Expand Up @@ -62,19 +62,19 @@ if [ "$kernel_index" -gt 1 ] ; then
if [ "$nb_snp_hap" -gt 1 ] ; then

for chromo_num_k in $(seq $nb_chromosomes -1 1)
do
do
if [ -d results_chromo_num_$chromo_num_k ]; then
rm -rf results_chromo_num_$chromo_num_k/*
else
mkdir results_chromo_num_$chromo_num_k
fi
fi
mv flanking_markers_of_tested_positions_in_kb_with_rlrt_value_on_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
mv flanking_markers_of_tested_positions_in_kb_with_significant_rlrt_value_on_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
mv flanking_markers_of_tested_positions_in_kb_with_significant_rlrt_value_on_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
if ls significant_haplotypes_chromo_num_$chromo_num_k* 1> /dev/null 2>&1; then
mv significant_haplotypes_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
fi
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_nb_hap_window_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_nb_hap_window_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv number_of_haplotypes_per_window_for_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
mv kernelized_haplotype_based_genome_scan_of_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
done
Expand All @@ -87,7 +87,7 @@ if [ "$kernel_index" -gt 1 ] ; then
mv number_of_haplotypes_per_window_for_complete_genome_scan* results_all_chromosomes
mv kernelized_haplotype_based_genome_scan_for_* results_all_chromosomes
mv flanking_markers_of_tested_positions_with_statistics* results_all_chromosomes

else

for chromo_num_k in $(seq $nb_chromosomes -1 1)
Expand All @@ -102,23 +102,23 @@ if [ "$kernel_index" -gt 1 ] ; then
if ls significant_snps_chromo_num_$chromo_num_k* 1> /dev/null 2>&1; then
mv significant_snps_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
fi
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv kernelized_gwas_of_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
done

if [ -d results_all_chromosomes ]; then
rm -rf results_all_chromosomes/*
else
mkdir results_all_chromosomes
fi
fi
mv kernelized_gwas_for_* results_all_chromosomes
mv markers_of_tested_positions_with_statistics.txt* results_all_chromosomes
rm vect_nb_hap_window_chromo_num_*

fi

else

if [ "$nb_snp_hap" -gt 1 ] ; then

for chromo_num_k in $(seq $nb_chromosomes -1 1)
Expand All @@ -133,8 +133,8 @@ if [ "$kernel_index" -gt 1 ] ; then
if ls significant_haplotypes_chromo_num_$chromo_num_k* 1> /dev/null 2>&1; then
mv significant_haplotypes_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
fi
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_nb_hap_window_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_nb_hap_window_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv number_of_haplotypes_per_window_for_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
mv haplotype_based_genome_scan_of_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
done
Expand Down Expand Up @@ -162,22 +162,22 @@ if [ "$kernel_index" -gt 1 ] ; then
if ls significant_snps_chromo_num_$chromo_num_k* 1> /dev/null 2>&1; then
mv significant_snps_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
fi
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv vect_rlrt_value_chromo_num_$chromo_num_k* results_chromo_num_$chromo_num_k
mv gwas_of_chromosome_$chromo_num_k* results_chromo_num_$chromo_num_k
done

if [ -d results_all_chromosomes ]; then
rm -rf results_all_chromosomes/*
else
mkdir results_all_chromosomes
fi
fi
mv gwas_for_* results_all_chromosomes
mv markers_of_tested_positions_with_statistics.txt* results_all_chromosomes
rm vect_nb_hap_window_chromo_num_*

fi
fi

fi
fi
clear

rm *.R
Expand Down
34 changes: 17 additions & 17 deletions khamix.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#=======================================================================#
# kernelized haplotype-based mixed model association mapping (KHAMIX) #
# kernelized haplotype-based mixed model association mapping (KHAMIX) #
#=======================================================================#
# source modules for R
# source module_load_r.sh
Expand All @@ -9,11 +9,11 @@
#1. setting haplotype size, in number of markers, and trait to be analyzed #
#--------------------------------------------------------------------------#
trait_name="LLGTH"
nb_snp_hap=6
nb_snp_hap=6
nb_chromosomes=12 # total number of chromosomes for the analyzed data set
kernel_index=1 # 1 for VanRaden linear kernel and 2 for Gaussian kernel (i.e. RBF)
kernel_index=1 # 1 for VanRaden linear kernel and 2 for Gaussian kernel (i.e. RBF)
signif_level=0.01 # significance level for the restricted likelihood ratio test (RLRT)
local_or_cluster=1 # 1 for local computation and 2 for parallelize computation on a cluster
local_or_cluster=2 # 1 for local computation and 2 for parallelize computation on a cluster

echo "$trait_name" > trait_name.txt
echo "$nb_snp_hap" > nb_snp_hap.txt
Expand Down Expand Up @@ -48,8 +48,8 @@ cp programs/compute_estimates_h0.R estimates_h0/
cd estimates_h0/
R -q --vanilla<get_data_trait_name.R
R -q --vanilla<get_data_incidence.R
R -q --vanilla<compute_k_matrix.R
R -q --vanilla<compute_estimates_h0.R
R -q --vanilla<compute_k_matrix.R
R -q --vanilla<compute_estimates_h0.R
cd ../

#-------------------------------------------------------------------------#
Expand All @@ -64,43 +64,43 @@ do
#3.1 creation of the directory for chromosome chromo_num_k to be analyzed #
#-------------------------------------------------------------------------#
mkdir genome_scan_chromo_num_$chromo_num_k

# copy data into the directory for chromosome chromo_num_k
mv chromo_num_k.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/nb_snp_hap.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/nb_chromosomes.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/genotypes.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/phased_genotypes.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/physical_map.txt genome_scan_chromo_num_$chromo_num_k
cp data_parameters/physical_map.txt genome_scan_chromo_num_$chromo_num_k

# copy data and estimates for model under null hypothesis (h0) into directory for chromosome chromo_num_k
cp estimates_h0/phenotypes_trait_name.txt genome_scan_chromo_num_$chromo_num_k
cp estimates_h0/x_matrix.txt genome_scan_chromo_num_$chromo_num_k
cp estimates_h0/z_u_matrix.txt genome_scan_chromo_num_$chromo_num_k
cp estimates_h0/k_matrix.txt genome_scan_chromo_num_$chromo_num_k
cp estimates_h0/emmreml_h0 genome_scan_chromo_num_$chromo_num_k

# copy programs into the directory for chromosome chromo_num_k
cp programs/get_data_chromo_num_k.R genome_scan_chromo_num_$chromo_num_k
cp programs/ibs_haplotypes_window genome_scan_chromo_num_$chromo_num_k
cp programs/compute_z_h_matrix genome_scan_chromo_num_$chromo_num_k
cp programs/emmreml_rlrt.R genome_scan_chromo_num_$chromo_num_k
cp programs/scan_chromo_num_k.sh genome_scan_chromo_num_$chromo_num_k
cp programs/scan_chromo_num_k.sh genome_scan_chromo_num_$chromo_num_k

# extract data associated to trait, fixed effects and compute Gram matrix (i.e. kernel matrix)
cd genome_scan_chromo_num_$chromo_num_k

# perform genome scan by sliding window for chromosome $chromo_num_k
# perform genome scan by sliding window for chromosome $chromo_num_k
if [ "$local_or_cluster" -gt 1 ] ; then
# qsub -q normal.q -v scan_chromo_num_k.sh # a cc2 queue
# sbatch scan_chromo_num_k.sh
qsub -q workq scan_chromo_num_k.sh
sbatch scan_chromo_num_k.sh
# qsub -q workq scan_chromo_num_k.sh
else
./scan_chromo_num_k.sh
fi

# moving to the next directory "genome_scan_chromo_num_$chromo_num_k",
# i.e. moving up the directory tree
cd ../
done
done

2 changes: 1 addition & 1 deletion make_scripts_programs_executable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
echo
chmod u+rwx module_load_R.sh
chmod u+rwx clean_scans.sh
chmod u+rwx khammix.sh
chmod u+rwx khamix.sh
chmod u+rwx get_results_scans.sh
chmod u+rwx programs/ibs_haplotypes_window
chmod u+rwx programs/compute_z_h_matrix
Expand Down
16 changes: 8 additions & 8 deletions programs/scan_chromo_num_k.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ chromo_num_k=$(cat "chromo_num_k.txt")
nb_snp_chromo_num_k=$(cat "nb_snp_chromo_num_k.txt")
nb_snp_hap=$(cat "nb_snp_hap.txt")

nb_scanned_positions=$(( nb_snp_chromo_num_k- $((nb_snp_hap-1)) ))
nb_scanned_positions=$(( nb_snp_chromo_num_k- $((nb_snp_hap-1)) ))

# genome scan for chromosome $chromo_num_k
for scanned_position in $( seq 1 1 $nb_scanned_positions )
do
echo "$scanned_position">scanned_position.txt
for scanned_position in $( seq 1 1 $nb_scanned_positions )
do
echo "$scanned_position">scanned_position.txt

#compute ibs status of haplotypes
./ibs_haplotypes_window
./compute_z_h_matrix

# compute restricted likelihood ratio from emmreml estimated parameters
R -q --vanilla<emmreml_rlrt.R
R -q --vanilla<emmreml_rlrt.R
cat rlrt_value.txt>>vect_rlrt_value_chromo_num_$chromo_num_k.txt
cat nb_col_h_matrix.txt>>vect_nb_hap_window_chromo_num_$chromo_num_k.txt
done
done
# end of genome scan for chromosome $chromo_num_k

0 comments on commit 70f1a29

Please sign in to comment.