From 0884c0cc0d3f72007c3596890e3857bcf34d9c4b Mon Sep 17 00:00:00 2001 From: Paolo Cozzi Date: Sat, 31 Aug 2024 17:35:53 +0200 Subject: [PATCH] :monocle_face: update smarter summary removed shadows from pie charts. Add sample by chip type for goats --- .../results/0.2.0-bunop-smarter_summary.ipynb | 51 ++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/notebooks/results/0.2.0-bunop-smarter_summary.ipynb b/notebooks/results/0.2.0-bunop-smarter_summary.ipynb index bf89616..07c3873 100644 --- a/notebooks/results/0.2.0-bunop-smarter_summary.ipynb +++ b/notebooks/results/0.2.0-bunop-smarter_summary.ipynb @@ -5,7 +5,7 @@ "id": "3cc84f47-db82-43eb-99fd-78768ecd2a99", "metadata": {}, "source": [ - "# SMARTER SUMMARY (2024/05/23)\n", + "# SMARTER SUMMARY (2024/08/31)\n", "* [Dataset composition](#datasets-composition)\n", " * [Foreground / background datasets](#foreground-vs-background-datasets)\n", " * [Datasets by chip type](#datasets-by-chip-type)\n", @@ -16,6 +16,7 @@ " * [Foreground / background samples for goat](#foreground-background-samples-goat)\n", " * [Greece foreground goat data](#greece-foreground-goat-data)\n", " * [Sweden foreground goat data](#sweden-foreground-goat-data)\n", + " * [Goat samples by chip type](#goat-sample-by-chip-type)\n", "* [Draw samples by country](#samples-by-country)\n", " * [Sheep samples by country](#sheep-samples-by-country)\n", " * [Goat samples by country](#goat-samples-by-country)\n", @@ -106,7 +107,7 @@ "metadata": {}, "outputs": [], "source": [ - "plot = datasets.value_counts(\"type\").plot.pie(y=\"type\", figsize=(8,8), shadow=True, startangle=45, rotatelabels=45, autopct='%1.1f%%')\n", + "plot = datasets.value_counts(\"type\").plot.pie(y=\"type\", figsize=(8,8), startangle=45, rotatelabels=45, autopct='%1.1f%%')\n", "_ = plt.title(\"Foreground vs Background genotype datasets\")\n", "plt.ylabel(None)\n", "plt.savefig('smarter-fgVsbg-datasets.png', dpi=300, bbox_inches='tight')\n", @@ -130,7 +131,7 @@ "metadata": {}, "outputs": [], "source": [ - "plot = datasets['chip_name'].value_counts().plot.pie(y=\"chip\", figsize=(8,8), shadow=True, startangle=45, rotatelabels=45, autopct='%1.1f%%')\n", + "plot = datasets['chip_name'].value_counts().plot.pie(y=\"chip\", figsize=(8,8), startangle=45, rotatelabels=45, autopct='%1.1f%%')\n", "_ = plt.title(\"Datasets by chip type\")\n", "plt.ylabel(None)\n", "plt.savefig('smarter-datasets-by-chips.png', dpi=300, bbox_inches='tight')\n", @@ -159,7 +160,7 @@ "foreground_sheep = SampleSheep.objects.filter(type_=\"foreground\").fields(country=True, breed=True, chip_name=True, locations=True)\n", "background_sheep = SampleSheep.objects.filter(type_=\"background\").fields(country=True, breed=True, chip_name=True, locations=True)\n", "samples_sheep = pd.Series({\"foreground\": foreground_sheep.count(), \"background\": background_sheep.count()}, name=\"Sheep\")\n", - "plot = samples_sheep.plot.pie(y=\"Sheep\", figsize=(8,8), shadow=True, startangle=90, rotatelabels=45, autopct='%1.1f%%')\n", + "plot = samples_sheep.plot.pie(y=\"Sheep\", figsize=(8,8), startangle=90, rotatelabels=45, autopct='%1.1f%%')\n", "_ = plt.title(\"Background VS Foreground sheep\")\n", "plt.ylabel(None)\n", "plt.savefig('sheep-foreground-vs-background-pie.png', dpi=300, bbox_inches='tight')\n", @@ -205,7 +206,7 @@ "metadata": {}, "outputs": [], "source": [ - "sheep_by_chip.plot.pie(y=\"count\", figsize=(8,8), shadow=True, startangle=-45, rotatelabels=45, autopct='%1.1f%%', legend=False)\n", + "sheep_by_chip.plot.pie(y=\"count\", figsize=(8,8), startangle=-45, rotatelabels=45, autopct='%1.1f%%', legend=False)\n", "_ = plt.title(\"Sheep samples by chip type\")\n", "plt.ylabel(None)\n", "plt.savefig('sheep-samples-by-chip-type.png', dpi=300, bbox_inches='tight')\n", @@ -345,7 +346,7 @@ "foreground_goats = SampleGoat.objects.filter(dataset__in=Dataset.objects.filter(type_=\"foreground\")).fields(country=True, breed=True, chip_name=True, locations=True, metadata=True)\n", "background_goats = SampleGoat.objects.filter(dataset__in=Dataset.objects.filter(type_=\"background\")).fields(country=True, breed=True, chip_name=True, locations=True, metadata=True)\n", "samples_goat = pd.Series({\"foreground\": foreground_goats.count(), \"background\": background_goats.count()}, name=\"Goats\")\n", - "plot = samples_goat.plot.pie(y=\"Goat\", figsize=(8,8), shadow=True, rotatelabels=45, autopct='%1.1f%%')\n", + "plot = samples_goat.plot.pie(y=\"Goat\", figsize=(8,8), rotatelabels=45, autopct='%1.1f%%')\n", "_ = plt.title(\"Background VS Foreground goats\")\n", "plt.ylabel(None)\n", "plt.savefig('goat-foreground-vs-background-pie.png', dpi=300, bbox_inches='tight')\n", @@ -479,6 +480,44 @@ "foreground_goats.value_counts('region')" ] }, + { + "cell_type": "markdown", + "id": "c59376dd", + "metadata": {}, + "source": [ + "\n", + "### Goat samples by chip type\n", + "Try to determine the sample composition by chip type:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33dd743b", + "metadata": {}, + "outputs": [], + "source": [ + "goat_by_chip = defaultdict(list)\n", + "for chip_name in SampleGoat.objects.distinct(\"chip_name\"):\n", + " goat_by_chip['chip_name'].append(chip_name)\n", + " goat_by_chip['count'].append(SampleGoat.objects.filter(chip_name=chip_name).count())\n", + "goat_by_chip = pd.DataFrame.from_dict(goat_by_chip).set_index(\"chip_name\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b78717e7", + "metadata": {}, + "outputs": [], + "source": [ + "goat_by_chip.plot.pie(y=\"count\", figsize=(8,8), startangle=-45, rotatelabels=45, autopct='%1.1f%%', legend=False)\n", + "_ = plt.title(\"Goat samples by chip type\")\n", + "plt.ylabel(None)\n", + "plt.savefig('goat-samples-by-chip-type.png', dpi=300, bbox_inches='tight')\n", + "plt.show()" + ] + }, { "cell_type": "markdown", "id": "8c3c128e-f8a7-47fd-812b-89266bcec1ca",