File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 5904
5904
}
5905
5905
],
5906
5906
"source": [
5907
- "ds = ds.sel(samples=((ds.sample_dp_mean >= 4) & (ds.sample_call_rate >= 0.97)))\n",
5907
+ "ds = ds.sel(samples=((ds.sample_dp_mean >= 4) & (ds.sample_call_rate >= 0.97)).compute() )\n",
5908
5908
"print(f\"After filter, {len(ds.samples)}/284 samples remain.\")"
5909
5909
]
5910
5910
},
9219
9219
"metadata": {},
9220
9220
"outputs": [],
9221
9221
"source": [
9222
- "ds = ds.sel(variants=((ds.variant_allele_frequency[:,1] > 0.01) & (ds.variant_hwe_p_value > 1e-6)))"
9222
+ "ds = ds.sel(variants=((ds.variant_allele_frequency[:,1] > 0.01) & (ds.variant_hwe_p_value > 1e-6)).compute() )"
9223
9223
]
9224
9224
},
9225
9225
{
11181
11181
"source": [
11182
11182
"# To run PCA we need to filter out variants with any missing alt allele counts\n",
11183
11183
"# Or where the counts are zero for all samples\n",
11184
- "variant_mask = ((ds_pca.call_alternate_allele_count < 0).any(dim=\"samples\")) | \\\n",
11185
- " (ds_pca.call_alternate_allele_count.std(dim=\"samples\") <= 0.0)\n",
11184
+ "variant_mask = ((( ds_pca.call_alternate_allele_count < 0).any(dim=\"samples\")) | \\\n",
11185
+ " (ds_pca.call_alternate_allele_count.std(dim=\"samples\") <= 0.0)).compute() \n",
11186
11186
"ds_pca = ds_pca.sel(variants=~variant_mask)"
11187
11187
]
11188
11188
},
Original file line number Diff line number Diff line change @@ -135,11 +135,11 @@ Call :meth:`xarray.Dataset.sel` on the ``variants`` dimension:
135
135
.. ipython :: python
136
136
137
137
ds2 = sg.hardy_weinberg_test(ds)
138
- ds2.sel(variants = (ds2.variant_hwe_p_value > 1e-2 ))
138
+ ds2.sel(variants = (ds2.variant_hwe_p_value > 1e-2 ).compute() )
139
139
140
140
.. note ::
141
141
142
- Filtering causes an eager Xarray computation .
142
+ The call to `` compute `` is needed to avoid an Xarray error .
143
143
144
144
Find which new variables were added by a method?
145
145
------------------------------------------------
You can’t perform that action at this time.
0 commit comments