TheWangLab / algatr

A Landscape Genomic Analysis Toolkit in R
https://thewanglab.github.io/algatr/
MIT License
15 stars 1 forks source link

bug in gen_dist #80

Closed ptitle closed 1 week ago

ptitle commented 1 week ago

Hi,

I believe there is a small bug in the function gen_dist(), which is preventing it from calculating certain distance types from a dosage matrix (which is what you have if imputing missing data).

library(algatr)
load_algatr_example()

# impute missing data
gen <- simple_impute(vcf_to_dosage(liz_vcf), median)

d <- gen_dist(gen, dist_type = "pc")

Error in vcfR::read.vcfR(x) :
  The parameter file is expected to be a character.

I think there is a missing parenthesis pair in line 24, and it should be: if (inherits(gen, "vcfR") & (dist_type == "euclidean" | dist_type == "bray_curtis" | dist_type == "pc")) {

If I make that change, then the flow of the function makes sense to me and it works.

AnushaPB commented 1 week ago

Thanks so much for pointing this out and solving it! I have just pushed the recommended changes