chr1swallace/coloc

Error when running `check_dataset()`

martaalcalde opened this issue · 3 comments

When running check_dataset() with argument req = "LD", it keeps appearing the error colnames in LD do not contain all SNP. I checked the function, and it is because the following criteria is not fulfilled: length(setdiff(d$snp,colnames(d$LD))). This is not meet as my d$snp is with the form rs1 whereas when computing the LD matrix, either row names and column names are with the form rs1_EffectAlleleValue_OtherAlleleValue.

I think it would be nice to generalise this to be able to include LD matrix that in their row names and column names include the alleles. I suggest just changing:

length(setdiff(d$snp,colnames(d$LD))) ---> length(d$snp) == length(colnames(d$LD))

And maybe, afterwards adding:

if(length(setdiff(d$snp,colnames(d$LD)))){
colnames(d$LD) <- gsub("_.*","",colnames(d$LD))
row.names(d$LD) <- gsub("_.*","",row.names(d$LD))

if(length(setdiff(d$snp,colnames(d$LD))){
Error("colnames in LD do not contain all SNP")
}
}

I hope is useful!

Hi Chris,

Thank you for your fast response. Makes sense! I'll close the issue.

All the best,

Marta