Hello,
I am trying to filter/join MatrixTable from VCF file and Table with Variants on alleles and locus.
Can you help me with the code? What is the right way to do it?
Best,
Hello,
I am trying to filter/join MatrixTable from VCF file and Table with Variants on alleles and locus.
Can you help me with the code? What is the right way to do it?
Best,
some code:
mt1 = hl.methods.import_vcf(vcf_file, contig_recoding=recode, force_bgz=True) var = pd.DataFrame({'chrom': ['1', '1'], 'pos': [12783, 13116], 'ref': ['G', 'T'], 'alt': ['A', 'G']}) ht = hl.Table.from_pandas(var) ht1 = ht.key_by(**hl.parse_variant(ht.chrom + hl.literal(':') + hl.str(ht.pos) + hl.literal(':') + ht.ref + hl.literal(':') + ht.alt))
and now I want to get from mt1 only the rows with locus and alleles which are in ht1
ht = hl.Table.from_pandas(var)
ht = ht.key_by(**hl.parse_variant(ht.chrom + hl.literal(β:β) + hl.str(ht.pos) + hl.literal(β:β) + ht.ref + hl.literal(β:β) + ht.alt))
ht = hl.MatrixTable.from_rows_table(ht)
ht = ht.select_rows()
ht = ht.select_cols()
ds_result = mt1.filter_rows(~hl.is_missing(ht.index_rows(mt1[βlocusβ], mt1[βallelesβ])))
ds_result.show()
this is the code