Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created October 20, 2015 12:40
Show Gist options
  • Save explodecomputer/3658efa255d9b646292e to your computer and use it in GitHub Desktop.
Save explodecomputer/3658efa255d9b646292e to your computer and use it in GitHub Desktop.
fourth meeting
manifest <- read.table("manifest.file")
# make sure IDs in manifest are matched to IDs in cpg matrix
tbetas_fom_subset <- t(tbetas[cpgs,])
tbetas_fom_subset[, 1] <- residuals(lm(tbetas_fom_subset[, 1] ~ manifest[,1:5]))
tbetas_fom_subset[, 2] <- residuals(lm(tbetas_fom_subset[, 2] ~ manifest[,1:5]))
tbetas_fom_subset[, 3] <- residuals(lm(tbetas_fom_subset[, 3] ~ manifest[,1:5]))
...
tbetas_fom_subset[, 12] <- residuals(lm(tbetas_fom_subset[, 12] ~ manifest[,1:5]))
for(i in 1:ncol(tbetas_fom_subset))
{
tbetas_fom_subset[, i] <- residuals(lm(tbetas_fom_subset[, i] ~ manifest[,1:5]))
}
plot(sort(tbetas_fom_subset[,1]))
cd /panfs/panasas01/shared/alspac/deprecated/aries/releasev2_apr2014
In R:
load("ALN.houseman450kData.FOM.releasev2_apr2014.Rdata")
counts <- houseman450kData$counts
manifest <- read.table("ARIES.manifest.releasev2_apr2014.txt", he=T, sep=",")
manifest_fom <- subset(manifest, time_point == "FOM")
manifest_antenatal <- subset(manifest, time_point == "antenatal")
residuals(lm ( tbetas_fom_subset[,1] ~ counts + manifest_fom$BCD_plate ))
#!/bin/bash
# Example of what a file looks like for extracting a set of IDs
awk '{ print $1, $2 }' data_chr01.fam | head -n 20 > ~/temp.fam
# Or in R:
a <- matrix(1:100, 10)
ids <- rownames(a)
ids <- data.frame(paste(ids, "M", sep=""), paste(ids, "M", sep=""))
write.table(ids, file="~/temp.fam", row=F, col=F, qu=F)
# How to extract SNPs and IDs and save to a new bed/bim/fam file set
plink1.90 --bfile data_chr01 --keep ~/temp.fam --extract snplist.txt --make-bed --out ~/temp
# Or extract to Additive format
plink1.90 --bfile data_chr01 --keep ~/temp.fam --extract snplist.txt --recode A --out ~/temp
https://www.cog-genomics.org/plink2/score
# Example of score file
rs1 A 0.1
rs2 G -0.2
rs3 T 0.3
# Create a score for each individual for each chromosome
plink --bfile data_chr01 --score scorefile.txt --out some_file_name
plink --bfile data_chr02 --score scorefile.txt --out some_file_name
plink --bfile data_chr03 --score scorefile.txt --out some_file_name
etc
for i in {01..23}
do
plink --bfile data_chr${i} --score scorefile.txt --out ~/some_file_name${i}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment