-
Notifications
You must be signed in to change notification settings - Fork 1
/
filtExp1.R
38 lines (22 loc) · 870 Bytes
/
filtExp1.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# R script to:
# 1. filters gene expression data set according to mean interquantile range and mean intensity
# 2. quantile normalize
# 3. outputs plink phenotype-file.
# Rscript ./scripts/filtExp1.R geneExpressionFile plinkFamFile phenoFileName
# by Boel Brynedal
args<-commandArgs(TRUE)
source('./scripts/filtFun.R')
library(mclust)
library(limma)
Exp=read.table(args[1],as.is=T,header=T,sep='\t',row.names=1)
###### filtering
IQR=filtIQR(Exp,0.8)
E=filtE(Exp,0.8)
filt=reduceFilt(IQR,E)
names(filt)=rownames(Exp)
Exp=Exp[filt,]
######### Quantile normalize the expression data post filtering
Exp=t(normalize.quantiles(Exp)
######### Output plink-pheno files
fam=read.table(args[2],as.is=T)
write.table(cbind(fam[which(fam[,2] %in% colnames(Exp)),1:2],t(Exp[,fam[which(fam[,2] %in% colnames(Exp)),2]])),quote=F,row.names=F,col.names=F,file=args[3])