R语言中实现统计基因的缺失率
001、
gene1 <- c(0,0,1,0) gene2 <- c(1,1,0,1) gene3 <- c(0,1,0,1) dat <- data.frame(gene1, gene2, gene3) ## 生成测试数据, 0表示基因缺失, 1表示基因存在 rate_0 <- function(x) ## 生成统计函数 { count = sum(x == 0) return(count/length(x)) } dat apply(dat, 2, rate_0) ## 借助apply函数输出所有基因的缺失率


浙公网安备 33010602011771号