KangchengHou / admix-kit

Toolkit for analyzing genetics data from admixed populations
https://kangchenghou.github.io/admix-kit
22 stars 5 forks source link

consistency between lanc and bp2anc.pl #18

Closed KangchengHou closed 1 year ago

KangchengHou commented 1 year ago

we should generate more complicated 3-way admixture and check consistency between lanc and bp2lanc.pl

import admix
import numpy as np
import pandas as pd

lanc1 = admix.data.Lanc("data/admix.lanc").dask().compute()
lanc2 = admix.io.read_digit_mat("data/admix.hanc").T

admix.plot.lanc(lanc=lanc1)

assert np.all(lanc2[:, 0::2] == lanc1[:, :, 0]) and np.all(
    lanc2[:, 1::2] == lanc1[:, :, 1]
)
KangchengHou commented 1 year ago

Seem to be consistent evaluated using the following code

import numpy as np
import pandas as pd
import admix

lanc1 = admix.data.Lanc("admix.lanc")
# first 100 individuals
lanc1 = lanc1[300:1800, 0:100].dask().compute()

lanc2 = admix.io.read_digit_mat("admix.hanc", nrows=200).T
lanc2 = lanc2[300:1800, :]

assert np.all(lanc2[:, 0::2] == lanc1[:, :, 0]) and np.all(
    lanc2[:, 1::2] == lanc1[:, :, 1]
)

admix.plot.lanc(lanc=lanc1)