[convert_geno_to_LD_matrix]

15 views
Skip to first unread message

yujin kim

unread,
Nov 21, 2024, 6:16:12 AM11/21/24
to ctwas_users
Dear ctwas group,

I ran the code below

##GET LD Matrix##
convert_geno_to_LD_matrix(
  region_info,
  "/data1/yujin/JH_BOMICs/CHR/MET_sample_FastQTL.chr1.bed",
  "/data1/yujin/JH_BOMICs/CHR/MET_sample_FastQTL.chr1.bim",
  chrom = 1,
  outputdir = "data1/yujin/JH_BOMICs/",
  outname = "",
  include_variance = TRUE,
  include_allele_freq = TRUE,
  show_progress_bar = TRUE,
  verbose = FALSE,
  logfile = NULL
)

then I got an error like below

2024-11-21 20:05:30.891674 INFO::Convert genotype data to LD matrices 2024-11-21 20:05:31.149244 INFO::Load variant information ... 2024-11-21 20:05:31.358821 INFO::No. regions in chr1: 82013 | | 0%
Error in `[.data.table`(ref_snpinfo_chr, sidx_ref, c("chrom", "id", "pos", : column(s) not found: [chrom] In addition: Warning message: In pgenlibr::ReadList(pgen, variant_subset = variantidx, meanimpute = meanimpute) : subscript out of bounds (index 0 >= vector size 0)

When I follow up the code, ref_snpinfo_chr was from ref_snp_all which is originated from the code "<- do.call(rbind, lapply(varinfo_files, read_var_info))"

function (read_var_info)

read_var_info <- function(var_info_file){
  if (file_ext(var_info_file) == "pvar"){
    var_info <- read_pvar(var_info_file)
  } else if (file_ext(var_info_file) == "bim"){
    var_info <- read_bim(var_info_file)
  } else{
    stop("unrecognized input")
  }
  return(var_info)
}

 is implemented by function(read_bim)

which is 
function (bimf)
{
    bim <- data.table::fread(bimf)
    colnames(bim) <- c("chr", "id", "cm", "pos", "alt", "ref")
    return(bim)
}

I thought it there is an issue with "chr"

Could you please tell me what was the problem?

Many thanks,

Yujin.

Kevin Luo

unread,
Nov 22, 2024, 12:04:15 PM11/22/24
to ctwas_users
Hi Yujin,

I suspect you may be using an older version of the package, where we used "chr" instead of "chrom". 

Can you update to the latest ctwas version and try again? 
remotes::install_github("xinhe-lab/ctwas",ref = "multigroup")

You can try the following and see it works for your bim file:
var_info <- ctwas:::read_var_info(varinfo_file)
head(var_info)

Best,
Kevin
Reply all
Reply to author
Forward
0 new messages