diff --git a/intro_stdpopsim_SMBE2024/Intro_stdpopsim.ipynb b/intro_stdpopsim_SMBE2024/Intro_stdpopsim.ipynb index 58391cf..359fcbd 100644 --- a/intro_stdpopsim_SMBE2024/Intro_stdpopsim.ipynb +++ b/intro_stdpopsim_SMBE2024/Intro_stdpopsim.ipynb @@ -370,6 +370,32 @@ "ts = engine.simulate(model, contig, samples, slim_scaling_factor=100, seed=1)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "We're getting a lot of warnings. Don't ignore these!\n", + "At least, don't ignore them until you figure out why they are happening.\n", + "Some of these are because we're using approximations to make the simulations go extra fast;\n", + "the warnings are telling us that the approximations are approximate - so: beware!\n", + "If you're just using these for development (like us) then no worries.\n", + "But, if you use them for production, make sure to evaluate whether the approximations\n", + "are affecting your results!\n", + "\n", + "This will turn off these warnings below:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import warnings\n", + "warnings.simplefilter(\"ignore\", category=stdpopsim.SLiMScalingFactorWarning)\n", + "warnings.simplefilter(\"ignore\", category=stdpopsim.UnspecifiedSLiMWarning)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -533,6 +559,7 @@ "metadata": {}, "outputs": [], "source": [ + "import numpy as np\n", "contig = species.get_contig(\"chr6\", left=0, right=100000)\n", "# make the DFE apply to the entire contig \n", "contig.add_dfe(intervals=np.array([[0, int(contig.length)]]), DFE=dfe)\n", @@ -667,7 +694,7 @@ "samples = #fill me!\n", "\n", "\n", - "contig = species.get_contig(\"\", length_multiplier=0.1) #fill me!\n", + "contig = species.get_contig(\"\", length_multiplier=0.001) #fill me!\n", "dfe = species.get_dfe(\"\") #fill me!\n", "exons = species.get_annotations(\"\") #fill me!\n", "exon_intervals = exons.get_chromosome_annotations(\"\") #fill me!\n", @@ -1101,7 +1128,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "now we're ready to do PCA. we'll do the decomposition and then plot, note that allel requires a flattened version of the genotype array above that codes individual genotypes as 0/1/2 according to the number of reference alleles" + "now we're ready to do PCA. we'll do the decomposition and then plot, note that allel requires a flattened version of the genotype array above that codes individual genotypes as 0/1/2 according to the number of reference alleles\n", + "\n", + "note: if you get an error here, you may need to re-run the simulation and try again" ] }, { @@ -1148,6 +1177,8 @@ "import stdpopsim\n", "from progressbar import ProgressBar #This is just to get a progress bar\n", "\n", + "import warnings\n", + "\n", "species = stdpopsim.get_species(\"HomSap\")\n", "model = species.get_demographic_model('OutOfAfrica_3G09')\n", "samples = {\"YRI\": 10, \"CHB\": 10, \"CEU\": 10}\n", @@ -1164,7 +1195,11 @@ "pi_list = []\n", "pbar = ProgressBar() #This is just to get a progress bar\n", "for i in pbar(range(n)):\n", - " ts = engine.simulate(model, contig, samples, slim_scaling_factor=20, slim_burn_in=10)\n", + " with warnings.catch_warnings():\n", + " warnings.simplefilter(\"ignore\", category=stdpopsim.SLiMScalingFactorWarning)\n", + " warnings.simplefilter(\"ignore\", category=stdpopsim.UnspecifiedSLiMWarning)\n", + " warnings.simplefilter(\"ignore\", category=UserWarning)\n", + " ts = engine.simulate(model, contig, samples, slim_scaling_factor=20, slim_burn_in=10)\n", " sample_list = make_sample_list(ts)\n", " pi_list.append(ts.diversity(sample_sets=sample_list))\n", "print('Done simulating {} replicates!'.format(n))\n", @@ -1358,7 +1393,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.12.4" } }, "nbformat": 4,