Error in ld(): STRING_ELT() can only be applied to a 'character vector', not a 'NULL'
0
0
Entering edit mode
Anastasiia • 0
@668f4503
Last seen 3.0 years ago
Poland

Hi all,

I am trying to calculate linkage disequilibrium using snpStats function ld()

But I keep receiving errors of all sorts. Below are 2 of my attempts to produce any result and the following errors

I don't know how to approach this problem

Thank you in advance

Anastasiia

#data
SNPMatrix <- read.plink('Ia.bed', 'a.bim', 'a.fam', sep= ".") 

# 1
LD_matrix <- ld(SNPMatrix, y = SNPMatrix, stats = "R.squared", symmetric = TRUE)
Error in ld(SNPMatrix, y = SNPMatrix, stats = "R.squared", symmetric = TRUE) : 
  STRING_ELT() can only be applied to a 'character vector', not a 'NULL'

#2
LD_matrix <- ld(SNPMatrix, depth = 100, stats = "R.squared") 
Error in if (depth > dmax) { : argument is of length zero


sessionInfo( )
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=pl_PL.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=pl_PL.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=pl_PL.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=pl_PL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] snpStats_1.44.0 Matrix_1.3-4    survival_3.2-13 LDheatmap_1.0-4

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7          pillar_1.6.4        compiler_4.1.2      zlibbioc_1.40.0     prettyunits_1.1.1   remotes_2.4.2       tools_4.1.2         testthat_3.1.0     
 [9] pkgbuild_1.2.1      pkgload_1.2.4       lattice_0.20-45     memoise_2.0.1       lifecycle_1.0.1     tibble_3.1.6        pkgconfig_2.0.3     rlang_0.4.12       
[17] rstudioapi_0.13     DBI_1.1.1           cli_3.1.0           curl_4.3.2          fastmap_1.1.0       withr_2.4.3         dplyr_1.0.7         generics_0.1.1     
[25] desc_1.4.0          fs_1.5.1            vctrs_0.3.8         devtools_2.4.3      grid_4.1.2          rprojroot_2.0.2     tidyselect_1.1.1    glue_1.5.1         
[33] R6_2.5.1            processx_3.5.2      fansi_0.5.0         sessioninfo_1.2.1   callr_3.7.0         purrr_0.3.4         magrittr_2.0.1      BiocGenerics_0.40.0
[41] splines_4.1.2       ps_1.6.0            ellipsis_0.3.2      usethis_2.1.3       assertthat_0.2.1    utf8_1.2.2          cachem_1.0.6        crayon_1.4.2
ld() snpStats • 1.5k views
ADD COMMENT
1
Entering edit mode

Can you confirm that SNPMatrix has been read correctly & contains the sort of data you're expecting? Perhaps check dim(SNPMatrix) and head(SNPMatrix) to confirm it looks ok.

Does the example from the ?ld manual page work for you?

library(snpStats)
data(testdata)
ld1 <- ld(Autosomes[, 1:50], depth=10, stats=c("D.prime", "R.squared"))
ld2 <- ld(Autosomes[, 1:20], Autosomes[, 21:25], stats="R.squared")
ADD REPLY
0
Entering edit mode

Hi, thank you for replying!

Examples work perfectly but I saw, that testdata doesn't look like my input data, I just wonder why those are 2 dataframes and not a SnpMatrix object

Anyways, when I try reading my files

SNPMatrix <- read.plink('a.bed', 'a.bim', 'a.fam', sep= ".")

it produces a large list of 3 elements

then:

dim(SNPMatrix)

RESULT: NULL

head(SNPMatrix)

RESULT:

$genotypes A SnpMatrix with 240 rows and 54209 columns Row names: AAS10 ... TRE9 Col names: IpsContig13_4598 ... IpsContig13_5972420

$fam pedigree member father mother sex affected AAS10 AAS10 AAS10 NA NA NA NA AAS18 AAS18 AAS18 NA NA NA NA AAS2 AAS2 AAS2 NA NA NA NA


SIL2-6 SIL2-6 SIL2-6 NA NA NA NA [ reached 'max' / getOption("max.print") -- omitted 74 rows ]

$map chromosome snp.name cM position allele.1 allele.2 IpsContig13_4598 IpsContig13 IpsContig13_4598 NA 4598 T A IpsContig13_4658 IpsContig13 IpsContig13_4658 NA 4658 C T IpsContig13_5091 IpsContig13 IpsContig13_5091 NA 5091 A G


[ reached 'max' / getOption("max.print") -- omitted 54043 rows ]

Sorry for the awkward output format, I also cut it for simplicity
So, read.plink does read my data somehow, but I can't be sure if everything is alright

ADD REPLY

Login before adding your answer.

Traffic: 552 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6