-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about bagging #21
Comments
Hi, I will try to answer all your questions.
# load a toy dataset from Loter `data` directory (assuming we are in Loter project root directory)
import os
import numpy as np
H_ceu = np.load(os.path.join("data", "H_ceu.npy"), allow_pickle=True)[:,:5000]
H_yri = np.load(os.path.join("data", "H_yri.npy"), allow_pickle=True)[:,:5000]
H_mex = np.load(os.path.join("data", "H_mex.npy"), allow_pickle=True)[:,:5000]
###### from here is the interesting code
# import
from loter.local_ancestry import boostrap_loter_multiple_pops, mode
# inout paramters
l_H=[H_ceu, H_yri]
h_adm=H_mex
range_lambda=np.arange(1.5, 5.5, 0.5)
nb_bagging=20
num_threads=8
# chunk of code to get bagging vote details
input_loter = (l_H, h_adm)
n, m = h_adm.shape
counts = np.zeros((len(l_H), n, m))
for l in range_lambda:
res_boostrap = boostrap_loter_multiple_pops(
*input_loter, lambd=l,
counts=counts, nbrun=nb_bagging,
num_threads=num_threads
)
# counts is a list containing arrays of number of votes per individual (in rows)
# and per SNP (in columns) for each reference populations
counts
# to get the majority vote
res_tmp = mode(counts)
You can also use the mode |
Hi, Thanks for your detailed answers. It is very helpful. best, |
Hi,
I have some question about bagging process.
res_loter = lc.loter_local_ancestry([H_ref1, H_ref2, H_ref3, H_ref4, H_ref5], H_query)
It seems that res_loter[1] only contained the number of the most frequent vote.
Is there any way to get the vote count for each population in the reference list? Because I want to mask some region as ambiguous when the count of the most frequent vote is close to the second vote.
best,
Yudong
The text was updated successfully, but these errors were encountered: