Hello,
I'm using a small data of 10 people to work with GENESIS and generate relatedness using PC-relate function. I generate .gds file, create kinship using KING. When generating principal components I get error Error in acc(object, NL[cnode]) : unmatched node provided
R 3.4.2
################--Code begins
bed<-"selected.bed"
fam<-"selected.fam" #10 people in sample data
bim<-"selected.bim"
snpgdsBED2GDS(bed, fam, bim, "9040.gds")
snpgdsSummary("9040.gds")
# read in GDS data
geno <- GdsGenotypeReader(filename = "9040.gds")
# create a GenotypeData class object
genoData <- GenotypeData(geno)
iids <- getScanID(genoData)
#head(iids) - looks good
KINGmat <- king2mat(file.kin0 = "small_data.kin0", iids = iids)
KINGmat[1:5,1:5] ## looks good. has colnames and rownames
mypcair <- pcair(genoData = genoData, kinMat = KINGmat, divMat = KINGmat)
##Error
###################--Code ends
Error:
Partitioning Samples into Related and Unrelated Sets...
Error in acc(object, NL[cnode]) : unmatched node provided
Version of packages used: GWASTools_1.24.1, Biobase_2.38.0, BiocGenerics_0.24.0, GENESIS_2.10.0, SNPRelate_1.14.0, gdsfmt_1.14.1, KING 2.1.2
Perhaps it's not able to find unrelated due to small sample size?
It took a while to chase down where this error is coming from. It turns out to be in the graph package:
My best guess is that your sample names are somehow not matching up with the expected values. If you could share your data so I have a reproducible example, I could look into it further. If that's not an option, you could try seeting
options(error=recover)
, which will help you figure out what is going on at the point in the code when that error is thrown. The above method is called from withinpcairPartition
(which is called from withinpcair
), so it might be easier to diagnose the problem if you runpcairPartition
on its own.You comment that the problem might be due to the small sample size may be correct. Can you try running the code with a larger dataset?
Thank you for your reply.
Yes, it works with larger sample size. Kinship I had with ten individuals had all negative values.
Thank you so so much for digging into this. :)
Hi Stephanie,
I am having a similar problem with the pcair function but it looks like the problem is kinMat$kinship matrix obtained from snpgdsIBDKING() has NaN values. Do you know why this happens? or how to overcome it?
Hello,
I played around with some sample data, and I have an idea of why you are observing NaN values in your kinMat$kinship matrix obtained from snpgdsIBDKING(). If I have individuals in my data set who have no observed heterozygous genotype calls at any of the variants being used in the test, then I get an NaN kinship estimate out for that individual with all other pairs.
This makes sense, as the KING robust kinship estimator divides by the number of heterozygous calls observed for each individual, and dividing by 0 is obviously NaN.
I'm not sure how many variants you're using in your analysis, but a couple thoughts on how to fix this issue:
If you are using lots of variants and still have individuals with no het calls, that certainly seems odd to me. You may want to dig into that further if that's the case.
Matt
Hi Matt,
Thanks. I just checked but all genotypes have het calls in my vcf.
Sorry, maybe what I was saying wasn't clear (or I'm misunderstanding what you said): It's not that every genotype needs to have a het call, it's that every individual needs to have a het call at some variants being used in your analysis. If that is true, then I'll try to dig some more.
A couple follow up questions:
Matt