Hello all, I have two MatrixTables, each corresponding to a sample, but with a different number of variants. Is there any way that I can compute the relatedness with two mts? I know there are methods like identity_by_descent
, but I am understanding that this is for samples within the same mt.
@rna , do the matrix tables contain the same variants?
If the matrix tables contain the same variants, you can mt.union_cols(other_mt)
and then use IBD, pc_relate, or KING.
No, they do not. If that is the case, is there a way to only retain the intersection of the variants, and then use any of those methods?
Yeah, you can restrict both to the shared variants:
x = hl.read_matrix_table(...)
y = hl.read_matrix_table(...)
shared = x.rows().join(y.rows())
shared.select().write('gs://.../shared.ht')
shared = hl.read_table('gs://.../shared.ht')
x = x.semi_join_rows(shared)
y = y.semi_join_rows(shared)
# you might also need to drop fields until they have the same schema
combined = x.union_cols(y)
hl.king(combined.GT)