Skip to content
Snippets Groups Projects
Commit 522ff6e1 authored by OTT Oceane's avatar OTT Oceane
Browse files

mod

parent 08c57764
No related branches found
No related tags found
No related merge requests found
wdir="."
dir.create(wdir, showWarnings = F, recursive = T)
setwd(wdir)
#library(devtools)
#library(plyr)
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
if (!require("snpStats", quietly = TRUE))
BiocManager::install("snpStats")
if (!require("SNPRelate", quietly = TRUE))
BiocManager::install("SNPRelate")
# Charger les bibliothèques
library(snpStats)
library(SNPRelate)
options(repos = c(CRAN = "https://cloud.r-project.org"))
output_dir = "results/tp1"
dir.create(output_dir, showWarnings = F, recursive = T)
# Les données analysées nécessitant beaucoup de RAM, nous allons sélectionner aléatoirement 250000 SNPs et réecrire des fichiers bed, bim, fam
penncath_bed_path = "results/data/penncath.bed"
penncath_bim_path = "results/data/penncath.bim"
penncath_fam_path = "results/data/penncath.fam"
geno <- snpStats::read.plink(penncath_bed_path, penncath_bim_path, penncath_fam_path, select.snps=sample(1:861473, 25000, replace = FALSE ), na.strings = ("-9"))
plink_base=file.path(output_dir, "plink_base")
snpStats::write.plink(plink_base, snps=geno$genotypes, pedigree=geno$fam[,1], id=geno$fam[,1], mother=geno$fam[,4], sex=geno$fam[,5], phenotype=geno$fam[,6], chromosome = geno$map[,1], genetic.distance = geno$map[,3], position = geno$map[,4], allele.1 = geno$map[,5], allele.2 = geno$map[,6], na.code = ("-9"))
genoBim<-geno$map
colnames(genoBim)<-c("chr", "SNP", "gen.dist", "position", "A1", "A2")
#head(genoBim)
genotype<-geno$genotype
#print(genotype)
genoFam<-geno$fam
#head(genoFam)
# On commence par libérer de l'espace
rm(geno)
rdata_path = file.path(output_dir, "TP1_asbvg.RData")
save.image(rdata_path)
# Makefile pour enchaîner deux scripts
# Cible par défaut (si 'make' est appelé sans argument)
all: tp1_output.txt
# Première étape : exécuter download_data.R
download_data_output.txt: ~/tp1ara/src/download_data.R
@echo "Running download_data.R..."
@Rscript ~/tp1ara/src/download_data.R > download_data_output.txt
@echo "download_data.R completed and output stored in download_data_output.txt."
# Deuxième étape : exécuter tp1.R en utilisant le résultat du premier script
tp1_output.txt: download_data_output.txt ~/tp1ara/src/tp1.R
@echo "Running tp1.R..."
@Rscript ~/tp1ara/src/tp1.R > tp1_output.txt
@echo "tp1.R completed and output stored in tp1_output.txt."
# Nettoyer les fichiers générés
clean:
@rm -f download_data_output.txt tp1_output.txt
@echo "Cleaned up output files."
......@@ -18,3 +18,4 @@ results/data/penncath.bed results/data/penncath.bim results/data/penncath.fam:
clean:
rm -rf results/data/penncath.bed results/data/penncath.bim results/data/penncath.fam results/data/penncath.csv results/penncath.tar.gz results/data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment