filter_poly <- function(data, missing_rate)
{
M <- data
n <- ncol(M)
a <- nrow(M)
TooManyBlanks <- NULL
for (i in 1:n){
m <- sum(M[,i]==1)
if (m > a*missing_rate) {TooManyBlanks <- c(TooManyBlanks, i)}
}
M <- M[,-TooManyBlanks] #| Remove MARKERS with >20% Missing Data
n <- ncol(M)
a <- nrow(M)
M[M==1] <- NA
#| Convert 1s to NA
vars <- matrix(NA, 1, n)
for (checkM in 1:n){ #| Find markers who are monomorphic
disone <- var(M[,checkM], na.rm = TRUE)
vars[1,checkM] <- disone
}
length(which(vars == 0))
rm_mono <- which(vars == 0)
M <- M[,-rm_mono]
K = str(rm_mono)
filt=M
return(filt)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.