Error with pcadapt function

184 views
Skip to first unread message

Pablo Dufflocq

unread,
Apr 24, 2022, 7:22:58 PM4/24/22
to dartR
Dear all,

I am trying to create an object to perform a pca analysis based on my dart dataset, however the R software returns the following warning message:

library(pcadapt)
library(ggplot2)
library(reshape2)

gl7_pcadapt <- read.pcadapt("./gl7_gds.bed",type = "bed")

x <- pcadapt(gl7_pcadapt, K = 20, min.maf = 0.01) 

Error in bedXPtr(input, n, p) : Sample-major mode is not supported.

Have you face with the same trouble before?, thanks in advance for your reply.
Cheers

Pablo

Jose Luis Mijangos

unread,
Apr 24, 2022, 7:58:10 PM4/24/22
to dartR
Hi Pablo,

I guess that you used dartR to convert from genlight to bed. There was a small in that function. I solve it and the updated version is available in the beta version of dartR. Below is some code to convert the genlight object and run pcadapt. for this work to work you need to download the PLINK executable and move it to your working directory. You can use dummy names, if you dont have information about the chromosome and position of your SNPs.

library(pcadapt)
library(devtools)
# installing the beta version of dartR
install_github("green-striped-gecko/dartR", ref = "beta", dependencies = TRUE,build_vignettes = TRUE)
# loading dartR
library(dartR)
# filtering on call rate
test <- gl.filter.callrate(platypus.gl,threshold = 1)
# assigning chromosome information
test$chromosome <- test$other$loc.metrics$Chrom_Platypus_Chrom_NCBIv1
# assigning position information
test$position <- test$other$loc.metrics$ChromPos_Platypus_Chrom_NCBIv1
# converting to bed file
gl2plink(test,bed_file = T,outpath = getwd())
# running pcadapt
gl7_pcadapt <- read.pcadapt("gl_plink.bed",type = "bed")

x <- pcadapt(gl7_pcadapt, K = 20, min.maf = 0.01)

Cheers,
Luis

Pablo Dufflocq

unread,
Apr 25, 2022, 1:00:48 PM4/25/22
to dartR
Dear Luis,

thank you for your reply and help. I followed all steps but I got this warning message when I try to convert the information to a bed file:

> gl2plink(test,bed_file = T, outpath = getwd())
Starting gl2plink
  Processing genlight object with SNP data
Error in names(x) <- value :
  'names' attribute [2] must be the same length as the vector [0]


Thanks in advance for your reply.

Cheers,
Pablo

Yael Rodger

unread,
May 29, 2022, 9:09:30 PM5/29/22
to dartR
Hi Pablo,

Did you find a solution to this? I have a similar error.

Cheers,

Yael

Pablo Dufflocq

unread,
May 30, 2022, 11:56:52 AM5/30/22
to da...@googlegroups.com
Dear Yael,

I did the following:
1.-Run pcadapt command lines in R 4.0.5 and save all created objects.
2.-Load the created objects in R 4.1.3 to continue with the analysis.

It worked for me.
Cheers.

Pablo

--
You received this message because you are subscribed to a topic in the Google Groups "dartR" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dartr/yMzplFdRRKQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/8f03c367-73dd-484c-902a-7a6c155abd14n%40googlegroups.com.

Gabriella Scatà

unread,
Jan 11, 2023, 3:40:14 AM1/11/23
to dartR
Hi everyone,
I am trying to run gl2plink as well, and I run in the same error:

"Error in names(x) <- value :
  'names' attribute [2] must be the same length as the vector [1]
"

Any updates on how to solve or overcome this issue?

I used exactly the same code as the one given by you @Luis in the message just above...
Please let me know.
Thanks a lot!
Gabriella

Brianna Coulter

unread,
Jan 12, 2023, 12:55:35 AM1/12/23
to dartR
Hi Gabriella,

You have to assign a value to the chromosome field or it won't write the plink file.

gl$chromosome <- as.factor("1")

Cheers,
Brianna.
Reply all
Reply to author
Forward
0 new messages