MRCIEU / gwasglue2

Connecting GWAS summary data to analytical tools
https://mrcieu.github.io/gwasglue2
Other
17 stars 2 forks source link

create_summaryset() error #58

Open bastal opened 11 months ago

bastal commented 11 months ago

Hi, I'm trying to use gwasglue2 for a large MR analysis. I tried using TwoSampleMR, but it was difficult because the server seems to have high traffic. When I try to use create_summaryset(), I get: "Error: Column(s) c("beta", "se", "p", "chr", "position", "rsid", "ea", "nea") is/are missing. Please specify." My code is below. Does anyone have insight into what the error means? Thank you!

library(gwasglue2) library(VariantAnnotation) library(gwasvcf) library(ieugwasr) library(dplyr)

Read MS dataset VCF file.

myvcffile <- "C://Users//brigi//Dropbox//dph//Dissertation//Post-defense//PLOS//MS//ieu-b-18.vcf.gz" myvcf<- readVcf(myvcffile)

get sig SNPs

ms8<- query_gwas(myvcf, pval = 5e-08 )

convert to summary stat format

ms8sum<-vcf_to_granges(ms8) ms8sumtib<-as_tibble(ms8sum)

create summary stats dataset

summs8<-create_summaryset( ms8sumtib, metadata = NULL, type = "tibble", qc = FALSE, beta_col = NULL, se_col = NULL, samplesize_col = NULL, pvalue_col = NULL, logpvalue_col = NULL, chr_col = NULL, position_col = NULL, rsid_col = NULL, effect_allele_col = NULL, other_allele_col = NULL, eaf_col = NULL, id_col = NULL, trait_col = NULL, build = NULL )

error message: Error: Column(s) c("beta", "se", "p", "chr", "position", "rsid", "ea", "nea") is/are missing. Please specify.

I also tried filling in the arguments like this, but got the same error:

summs8<-create_summaryset( ms8sumtib, metadata = NULL, type = "tibble", qc = FALSE, beta_col = "beta", se_col = "se", samplesize_col = "n", pvalue_col = "p", chr_col = "chr", position_col = "position", rsid_col = "rsid", effect_allele_col = "ea", other_allele_col = "nea", eaf_col = "eaf", id_col = "id", trait_col = "trait", build = "GRCh37" )

ritarasteiro commented 11 months ago

Hi, It appears you are using vcf files. Look at this tutorial.

In create_summaryset(), change the type argument to type="vcf" . It will change automatically the vcf column names to the gwasglue2 format.

Thus in your code,

summs8 <- gwasvcf::query_gwas(myvcf, pval = 5e-08) %>% gwasvcf::vcf_to_granges() %>% dplyr::as_tibble() %>% gwasglue2::create_summaryset(type="vcf")

Or simply use gwasvcf::gwasvcf_to_summaryset():

summs8 <- gwasvcf::query_gwas(myvcf, pval = 5e-08 ) %>% gwasvcf::gwasvcf_to_summaryset()