source
filter_variants
filter_variants ()
source
count_variants
count_variants (vcf_file)
Count the number of variants in a VCF file using subprocess.
source
read_vcf
read_vcf (vcf_file)
Reads a VCF file, automatically detecting the header and using correct column names.
source
expand_multiallelic_variants
expand_multiallelic_variants (df_vcf)
Extracts allele counts (RO, AO, DP) for each sample from the VCF DataFrame and expands multi-allelic variants into separate rows.
source
find_index
find_index (format_value, field)
Finds the index of a specific field (e.g., RO, AO, DP) in the FORMAT column.
source
compute_frequencies
compute_frequencies (df_counts)
Computes allele frequency (AF = AO / DP) for each sample in the dataset.
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/fastcore/docscrape.py:230: UserWarning: Unknown section Parameters:
else: warn(msg)
/opt/hostedtoolcache/Python/3.10.18/x64/lib/python3.10/site-packages/fastcore/docscrape.py:230: UserWarning: Unknown section Returns:
else: warn(msg)
source
add_ann_info_to_df
add_ann_info_to_df (df, info_column='INFO')
Extract the first ANN annotation from the INFO field and add as separate columns to a DataFrame.
source
clean_axes
clean_axes (ax, offset=10)
Customizes a matplotlib axes by removing top and right spines, and creating a broken axis effect where x and y axes don’t touch.
source
mod_hist_legend
mod_hist_legend (ax, title=False)
*Creates a cleaner legend for histogram plots by using line elements instead of patches.
Motivation: - Default histogram legends show rectangle patches which can be visually distracting - This function creates a more elegant legend with simple lines matching histogram edge colors - Positions the legend outside the plot to avoid overlapping with data*
source
make_circos_plot
make_circos_plot (data)
source
elbow_point
elbow_point (values)
Find the elbow point in a curve using the maximum curvature method.
| values |
list |
The y-values of the curve. |
| Returns |
int |
The index of the elbow point. |
source
kmeans_cluster_analysis
kmeans_cluster_analysis (df, cluster_sizes, random_state=42,
features=None, figsize=(12, 6),
standardize=False, fill_na=False)
Perform K-means clustering analysis on a pandas DataFrame and visualize the results with both normalized inertia and silhouette scores on the same plot.
| df |
pandas.DataFrame |
|
The input data to cluster. |
| cluster_sizes |
list |
|
List of cluster sizes (k values) to evaluate. |
| random_state |
int |
42 |
Random seed for reproducibility (default: 42). |
| features |
NoneType |
None |
List of column names to use for clustering. If None, all columns are used. |
| figsize |
tuple |
(12, 6) |
Figure size for the output plot (default: (12, 6)). |
| standardize |
bool |
False |
Whether to standardize the features (default: False). |
| fill_na |
bool |
False |
Whether to fill missing values with column means (default: False). |
| Returns |
tuple |
|
(figure, inertia_values, silhouette_values) - The matplotlib figure object, the list of inertia values, and the list of silhouette scores. |