Skip to content

Commit

Permalink
Refactor SNPObject and improve docstrings
Browse files Browse the repository at this point in the history
- Rename average_strands to is_phased.
- Add common_variants_intersection to subset_to_common_variants.
- Add common_markers_intersection to subset_to_common_markers.
- Rename filename to file.
- Rename correct_snp_variants to correct_flipped_variants.
- Refine docstrings for improved clarity and consistency.
  • Loading branch information
miriambt committed Nov 15, 2024
1 parent 392fef9 commit f648e4d
Show file tree
Hide file tree
Showing 2 changed files with 315 additions and 308 deletions.
34 changes: 20 additions & 14 deletions demos/SNPObj.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 1,
"id": "674d136a-1ded-4ce0-babc-87556d518b5f",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -319,7 +319,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Unique genotype values before renaming missings: [0 1]\n",
"Unique genotype values before renaming missings: [0 1]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Unique genotype values after renaming missings: [0 1]\n"
]
}
Expand Down Expand Up @@ -424,13 +430,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Number of SNPs before filtering by indexes: 976599\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of SNPs before filtering by indexes: 976599\n",
"Number of SNPs after filtering by indexes: 3\n"
]
}
Expand Down Expand Up @@ -466,7 +466,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Samples before filtering: ['sample_A', 'sample_B', 'sample_C', 'sample_D']\n",
"Samples before filtering: ['sample_A', 'sample_B', 'sample_C', 'sample_D']\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Samples after filtering: ['sample_A', 'sample_B']\n"
]
}
Expand Down Expand Up @@ -657,7 +663,7 @@
}
],
"source": [
"snpobj_corrected = snpobj.correct_snp_variants(snpobj2, check_complement=True, index_by='pos', inplace=False)\n",
"snpobj_corrected = snpobj.correct_flipped_variants(snpobj2, check_complement=True, index_by='pos', inplace=False)\n",
"\n",
"print(\"SNP flips corrected.\")"
]
Expand Down Expand Up @@ -728,7 +734,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"First 5 variant positions after shuffling: [14258595 13978490 23721180 30763191 42617482]\n"
"First 5 variant positions after shuffling: [45903479 41864913 32108927 26948879 19065364]\n"
]
}
],
Expand Down Expand Up @@ -834,7 +840,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 26,
"id": "fbca1fd8",
"metadata": {},
"outputs": [
Expand Down Expand Up @@ -873,7 +879,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 27,
"id": "cea856ad",
"metadata": {},
"outputs": [
Expand Down
Loading

0 comments on commit f648e4d

Please sign in to comment.