library(reshape2)
load("54Riskfactors-4DR_oneP_adj(basedIVs).RData")
df1 <- dat_adj[which(dat_adj$padj < 0.05),]
df2 <- dat_adj[dat_adj$riskfactors %in% df1$riskfactors,]
mat_beta<- dcast(df2,riskfactors~DR,value.var = "rawBeta")
mat_beta[is.na(mat_beta)] <- 0
microrowname <- mat_beta[,1]
mat_beta <- mat_beta[,-1]
mat_beta =apply(mat_beta ,2,as.numeric)
rownames(mat_beta) <- microrowname
mat_beta <- as.matrix(mat_beta)
m <- apply(mat_beta,1,function(x) { length(table(x >= 0)) > 1 & length(table(x <= 0)) > 1 })
names <- rownames(mat_beta)[m]
names
[1] "PECAM-1" "SELE"
microrowname[!microrowname %in% names]
[1] "2hGlu" "bmi"
R 筛选掉数据正负不一致的行
于 2023-02-15 09:58:49 首次发布