复制
收藏
提问
简洁
outcome_data <- read_outcome_data( + filename = "outcome_all_gut.csv", + sep = ",", + snp_col = "rsID", + beta_col = "beta", + se_col = "SE", + phenotype_col = "bac", + effect_allele_col = "eff.allele", + other_allele_col = "ref.allele", + chr_col = "chr", + pos_col = "bp", + snps = exposure_data$SNP) Error in `$<-.data.frame`(`*tmp*`, "mr_keep.outcome", value = TRUE) : 替换数据里有1行,但数据有0
14小时前
全网
文档
学术
百科
知识库
回答简洁模式
深入研究一些
读取outcome数据时遇到错误,原因是数据框中没有匹配的SNP行。4
错误原因
- SNP匹配失败:暴露数据和结局数据中的SNP列不匹配,导致无法找到正确的行。4
解决方案
- 检查SNP列:确保暴露数据和结局数据中的SNP列是包含与被包含关系。4
- 数据预处理:使用
format_data()
函数将数据转化为TwoSampleMR格式。11 - 重新读取数据:确保
read_outcome_data()
函数的参数正确,特别是snp_col
和snps
参数。3
示例代码
# 使用format_data()函数预处理数据
formatted_data <- format_data(outcome_all_gut, type = "outcome", snp_col = "rsID", beta_col = "beta", se_col = "SE", phenotype_col = "bac", effect_allele_col = "eff.allele", other_allele_col = "ref.allele", chr_col = "chr", pos_col = "bp")
# 重新读取outcome数据
outcome_data <- read_outcome_data(
filename = "outcome_all_gut.csv",
sep = ",",
snp_col = "rsID",
beta_col = "beta",
se_col = "SE",
phenotype_col = "bac",
effect_allele_col = "eff.allele",
other_allele_col = "ref.allele",
chr_col = "chr",
pos_col = "bp",
snps = exposure_data$SNP)
你觉得结果怎么样?