Skip to content

Commit

Permalink
PSW-97: Improve docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
miriambt committed Dec 5, 2024
1 parent c1ee59b commit 40ab5bb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions snputils/ancestry/genobj/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,9 +506,12 @@ def convert_to_snp_level(
variants_qual: Optional[np.ndarray] = None
) -> 'SNPObject':
"""
Convert the current `WindowLevelAncestryObject` to an `SNPObject` with SNP-level ancestry data.
If `variants_pos` and `variants_chrom` are not provided, they will be generated by creating all SNPs between
the start and end positions of each window.
Convert `self` into a `snputils.snp.genobj.SNPObject` SNP-level Local Ancestry Information (LAI),
with optional support for Single Nucleotide Polymorphism (SNP) data.
If SNP positions (`variants_pos`) and chromosomes (`variants_chrom`) are not specified, the method generates
SNPs uniformly across the start and end positions of each genomic window. Otherwise, the provided SNP
coordinates are used to assign ancestry values based on their respective windows.
Args:
variants_chrom (array of shape (n_snps,), optional):
Expand All @@ -527,7 +530,8 @@ def convert_to_snp_level(
An array containing the Phred-scaled quality score for each SNP.
Returns:
SNPObject: SNP-level ancestry object.
SNPObject:
A `SNPObject` containing SNP-level ancestry data, along with optional metadata.
"""
n_samples = self.n_samples

Expand Down Expand Up @@ -625,7 +629,7 @@ def convert_to_snp_level(
valid_window_indices = snp_to_window_indices[valid_snp_indices]

# Assign lai_values to calldata_lai for all valid SNPs at once
calldata_lai[valid_snp_indices] = self.lai[valid_window_indices][:, np.newaxis, :] # Shape: (num_valid_snps, 1, 2)
calldata_lai[valid_snp_indices] = lai_reshaped[valid_window_indices]

return SNPObject(
calldata_lai=calldata_lai,
Expand Down

0 comments on commit 40ab5bb

Please sign in to comment.