Created
October 21, 2014 19:32
-
-
Save xingpel/e2d38066184eb0237a5d to your computer and use it in GitHub Desktop.
NGS-Data-Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter <- function(threshold,zeros,countData){ | |
#1,threshold is the critical mean value of each row; | |
#2,countdata is the input original countdata that is going to filter; | |
#3,zeros is the critical number of zero reads that each row contained that would filtered out, | |
#every row that contain more than this number of zero reads will be deleted. | |
Means <- rowMeans(countData, na.rm = FALSE) | |
fullcountdata <- cbind(countData,Means) | |
filcountdata <- subset(fullcountdata,Means>threshold) | |
filcountdata$Means <- NULL | |
#delete the rows that have zero reads less than "zeros" number. | |
filcountdata<-filcountdata[rowSums(filcountdata==0)<=zeros,] | |
#save the filtered data into the csv file called filcountdata.csv | |
write.csv(filcountdata,file="filcountdata.csv") | |
filcountdata | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment