chr1swallace / coloc

Repo for the R package coloc
138 stars 44 forks source link

XtX is not symmetric #136

Closed mocksu closed 8 months ago

mocksu commented 8 months ago

I used plink to generate the pairwise LD, converted it into a tab delimited file as follows:

rs112826008 rs10159087  rs4655836   rs189496881 rs598961 ...
1   0   -0.00399602 -0.00801603 -0.12655 ...
0   1   0   0   0 ...
-0.00399602 0   1   -0.00399602 -0.0630858 ...
-0.00801603 0   -0.00399602 1   -0.0621224 ...
-0.12655    0   -0.0630858  -0.0621224  1 ...
...

Then read the above file into a matrix ("mat1" or "mat2" below)


    mat1 = as.matrix(read.table('mat1.txt', sep='   ', header=T))
    mat2 = as.matrix(read.table('mat2.txt', sep='   ', header=T))

    rownames(mat1) = colnames(mat1)
    rownames(mat2) = colnames(mat2)

    ds1$LD = mat1
    ds2$LD = mat2

I tried "check_dataset(..)" and "runsusie(..)" and got responses as follows:

>check_dataset(ds1,req="LD")
NULL
Warning messages:
1: In if (!(d$type %in% c("quant", "cc"))) stop("dataset ", suffix,  :
  the condition has length > 1 and only the first element will be used
2: In if (!(d$type %in% c("quant", "cc"))) stop("dataset ", suffix,  :
  the condition has length > 1 and only the first element will be used
> s1 = runsusie(ds1)
running max iterations: 100
WARNING: XtX is not symmetric; forcing XtX to be symmetric by replacing XtX with (XtX + t(XtX))/2
Error in init_finalize(s) : 
  Input residual variance sigma2 must be a scalar
In addition: Warning messages:
1: In if (!(d$type %in% c("quant", "cc"))) stop("dataset ", suffix,  :
  the condition has length > 1 and only the first element will be used
2: In if (!(d$type %in% c("quant", "cc"))) stop("dataset ", suffix,  :
  the condition has length > 1 and only the first element will be used
3: In if (n <= 1) stop("n must be greater than 1") :
  the condition has length > 1 and only the first element will be used
4: In if (n <= 1) stop("n must be greater than 1") :
  the condition has length > 1 and only the first element will be used
> mat1[0:5,0:5]
            rs112826008 rs10159087   rs4655836 rs189496881   rs598961
rs112826008  1.00000000          0 -0.00399602 -0.00801603 -0.1265500
rs10159087   0.00000000          1  0.00000000  0.00000000  0.0000000
rs4655836   -0.00399602          0  1.00000000 -0.00399602 -0.0630858
rs189496881 -0.00801603          0 -0.00399602  1.00000000 -0.0621224
rs598961    -0.12655000          0 -0.06308580 -0.06212240  1.0000000
> s1
Error: object 's1' not found

As I checked by "identical(matrix, t(matrix))", the two matrices are symmetric.

BTW, "ds1" and "ds2" can be used to do "coloc.abf(..)" just fine.

I need to do susie coloc but I am not sure what's wrong.

Thanks for any advice!

mocksu commented 8 months ago

Got this fixed by making N and type scalar.