How can I combine a kinship matrix with subset individuals when using rvtests? I've been processing data for a consortium project that uses the rvtests toolkit. Our data analysis process uses a kinship matrix and the calculation of inverse-normalised transformed statistics after covariate adjustment (for 1kG-imputed data from a SNPchip). One of the operations we have been asked to do is to analyse males and females separately for a number of different phenotypes.

Here's an example of the command line that I'm running:

rvtest --inVcf chr${ch}.imputed.poly.vcf.gz \
 --pheno ../scripts/phenotypes.raw.2017-May-01.ped \
 --pheno-name ${traitName} \
 --out rv_results/${traitName}_FEMALE_chr${ch} \
 --kinship kinship_matrix.kinship \
 --meta score,cov[windowSize=500000] \
 --peopleIncludeFile ../scripts/female.iids.txt \
 --covar ../scripts/covar.2017-May-11.ped \
 --covar-name ${covs} --useResidualAsPhenotype --dosage DS


Unfortunately, the kinship matrix doesn't interact well with the --peopleinclude parameter. When I run this, the program complains about unexpected columns in the kinship matrix (starting at one column greater than the number of females in the dataset). I suspect what is happening is that rvtests is assuming that the kinship matrix applies to the sample set after filtering, rather than applying to the total sample set. This sets off a few warning bells in my head, because it means that rvtest is probably ignoring the column/row labels in the kinship matrix that it has generated.

How can I work around this problem?
Adam Locke (a collaborator of this project) suggests that removing covariate information for the unselected individuals (i.e. setting it to NA) works around this problem:


  I believe the problem is that he is using a pre-computed kinship matrix including both males and females, and when using the “—peopleIncludeFile” it can’t properly select the right people from the kinship matrix. I don’t know that others have tried to do analysis this way. An alternative, that I think has worked for others, is to generate phenotype variables that have values only for males or females (so, e.g., BMI, BMI_females, BMI_males). For whatever reason, this appears to correctly only use the and select the samples desired without the kinship matrix.


Presumably a kinship matrix that is generated for just the subset individuals will work as well, although I don't like the idea that rvtests isn't able to do a label lookup on the kinship matrix to find the correct individuals.