bcm-uga / pcadapt

Performing highly efficient genome scans for local adaptation with R package pcadapt v4
https://bcm-uga.github.io/pcadapt
37 stars 10 forks source link

error with vcf2pcadapt command #30

Closed fkatharina closed 5 years ago

fkatharina commented 5 years ago

Dear Michael,

I wonder if you could help with an error I encounter using the pcadapt package? I am following the manual to load vcf data into R, wanting to dentify outlier loci using the pcadapt command.

I first read the data into R using vcfR, as the manual suggests: data <- read.vcfR("data.vcf")

However, when I then use the following command for conversion, I get an error message: data_pcadapt <- vcf2pcadapt(data, output = "data.pcadapt", allele.sep = c("/", "|")) Error in vcfR::read.vcfR(input, verbose = FALSE) : The parameter file is expected to be a character.

I have already browsed the web but cannot understand why it would not recognize the vcf file if I loaded it according to pcadapt-manual-instructions...?

Any advice you can provide would be greatly appreciated.

best regards, Katharina

Mary-00 commented 5 years ago

Hi, I also recently use pcadapt (v 4.0.3), the below command works well and reads the vcf file: vcf2pcadapt(data, output = "data.pcadapt", allele.sep = c("/", "|"))

Best

fkatharina commented 5 years ago

Hi Mary, thanks for your reply. This is exactly the same command I am using, but I continuously get this error: Error in vcfR::read.vcfR(input, verbose = FALSE) : The parameter file is expected to be a character.

With which command did you load your vcf file into R?

I load it with vcfR and when doing this get a "large vcfR" object. Is this the same for you?

thanks , Katharina

Mary-00 commented 5 years ago

I used just this command to load vcf to the package. Please try it without your first command.

Hope it helps

privefl commented 5 years ago

Note that you should not use vcf2pcadapt. The correct way to use pcadapt (for any type of data, here vcf) is to use

filename <- read.pcadapt(path_to_vcf, type = "vcf")
x <- pcadapt(filename, K = 20) 
Mary-00 commented 5 years ago

Hi Privefl, I used that command to convert vcf file to pcadapt format based on the manual. then used file2 <- read.pcadapt ("file.pcadapt", type="pcadapt") and other steps and get the results without error. however, my results are a bit strange that posted as an issue here.

mblumuga commented 5 years ago

@Mary-00 and @fkatharina, can you use the solution proposed by @privefl and tell us if it works.

fkatharina commented 5 years ago

just gave it a try and it works, many thanks to all and particularly to @privefl for the right solution!

mblumuga commented 5 years ago

Great, glad that it works.