{ "cells": [ { "cell_type": "markdown", "id": "1b3c57f9", "metadata": {}, "source": [ "# Sequenced Genomes — NCBI RefSeq Assembly Catalogue\n", "\n", "Starter notebook for the Kaggle dataset in this folder. It loads `genome_assemblies.csv` with pandas and walks through quality checks and a first piece of analysis.\n", "\n", "**Files:** `genome_assemblies.csv`, `data_dictionary.csv`." ] }, { "cell_type": "markdown", "id": "0000f7f2", "metadata": {}, "source": [ "## 1. Load the data" ] }, { "cell_type": "code", "id": "e3ba025f", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import pandas as pd\n", "\n", "df = pd.read_csv(\"genome_assemblies.csv\", low_memory=False)\n", "print(df.shape)" ] }, { "cell_type": "markdown", "id": "325de123", "metadata": {}, "source": [ "## 2. Shape, types and missing values" ] }, { "cell_type": "code", "id": "6eb42bc8", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "print(f\"{df.shape[0]:,} rows x {df.shape[1]} columns\")\n", "\n", "missing = df.isna().mean().mul(100).sort_values(ascending=False)\n", "missing[missing > 0].round(1).to_frame(\"missing_%\").head(15)" ] }, { "cell_type": "markdown", "id": "f2d963fe", "metadata": {}, "source": [ "## 3. Numeric summary" ] }, { "cell_type": "code", "id": "aa2f8fd4", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.describe(include='number').T.round(2).head(20)" ] }, { "cell_type": "markdown", "id": "ace4035c", "metadata": {}, "source": [ "## 4. Assemblies by organism group" ] }, { "cell_type": "code", "id": "a59ad746", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"group\"].value_counts().head(12).plot(kind=\"bar\", figsize=(11, 4))" ] }, { "cell_type": "markdown", "id": "8af66f30", "metadata": {}, "source": [ "## 5. Genome size distribution" ] }, { "cell_type": "code", "id": "6cf7d767", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[\"genome_size_mb\"].dropna().clip(upper=5000).hist(bins=80, figsize=(10, 4))" ] }, { "cell_type": "markdown", "id": "b9f823da", "metadata": {}, "source": [ "## 6. Assembly level over time" ] }, { "cell_type": "code", "id": "a11deb55", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "pd.crosstab(pd.to_numeric(df[\"seq_rel_year\"], errors=\"coerce\"), df[\"assembly_level\"]).tail(20).plot(figsize=(11, 4))" ] }, { "cell_type": "markdown", "id": "68ffaa1a", "metadata": {}, "source": [ "## 7. Largest genomes" ] }, { "cell_type": "code", "id": "c0c8d192", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.nlargest(12, \"genome_size_mb\")[[\"organism_name\", \"assembly_level\", \"genome_size_mb\", \"total_gene_count\"]]" ] }, { "cell_type": "markdown", "id": "ef44211f", "metadata": {}, "source": [ "## 8. GC content by group" ] }, { "cell_type": "code", "id": "d36cf752", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df.boxplot(column=\"gc_percent\", by=\"group\", figsize=(13, 4), rot=90)" ] }, { "cell_type": "markdown", "id": "679e0f43", "metadata": {}, "source": [ "## 9. Gene density" ] }, { "cell_type": "code", "id": "687f5e0d", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "df[[\"genes_per_mb\", \"genome_size_mb\"]].dropna().sample(5000, random_state=0).plot.scatter(x=\"genome_size_mb\", y=\"genes_per_mb\", alpha=0.2, logx=True)" ] }, { "cell_type": "markdown", "id": "6e43770c", "metadata": {}, "source": [ "## Next steps\n", "\n", "See `KAGGLE.md` for analysis ideas, caveats and provenance." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11", "mimetype": "text/x-python", "file_extension": ".py", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python" } }, "nbformat": 4, "nbformat_minor": 5 }