Skip to content

Commit

Permalink
Update model_comparison_analysis.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesostner committed Oct 19, 2021
1 parent 55d4737 commit 15b5f4a
Showing 1 changed file with 181 additions and 0 deletions.
181 changes: 181 additions & 0 deletions benchmarking/model_comparison_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,187 @@
}
}
},
{
"cell_type": "markdown",
"source": [
"We want to show one example benchmarking dataset that captures the essence of scCODA:\n",
"Compositional analysis on low-replicate data.\n",
"Thus, we choose one where we have an effect that is large (log-fold = 2)\n",
"and the replicate number is low (2 samples per group)."
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 6,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"relevant indices: Int64Index([4740, 4741, 4742, 4743, 4744, 4745, 4746, 4747, 4748, 4749, 4750,\n",
" 4751, 4752, 4753, 4754, 4755, 4756, 4757, 4758, 4759],\n",
" dtype='int64')\n"
]
}
],
"source": [
"save_path = \"../../sccoda_benchmark_data/model_comparison/data_model_comparison/\"\n",
"\n",
"# read generation parameters and find one where we have an increase that is large\n",
"# and replicate number is low\n",
"gen_params = pd.read_csv(save_path + \"generation_parameters\", index_col=0)\n",
"print(f'relevant indices: {gen_params.loc[(gen_params[\"n_controls\"]==2) & (gen_params[\"log-fold increase\"]==2) & (gen_params[\"Base\"]==1000)].index}')\n",
"\n",
"# choose one dataset as example (e.g. number 2304 one with these properties)\n",
"example_index = 4744\n",
"example_params = gen_params.iloc[example_index, :]"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"We select one dataset that matches these criteria (here the fourth).\n",
"The raw counts look like this:"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 7,
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Observation names are not unique. To make them unique, call `.obs_names_make_unique`.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 906. 1370. 1056. 861. 807.]\n",
" [1288. 804. 1061. 895. 952.]\n",
" [3734. 275. 264. 270. 457.]\n",
" [4038. 244. 156. 282. 280.]]\n"
]
}
],
"source": [
"# read all generated data and pick the one we selected\n",
"datasets = ad.read_h5ad(save_path + \"generated_data\")\n",
"example_data = datasets[datasets.obs[\"dataset_no\"] == example_index]\n",
"\n",
"print(example_data.X)\n"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"First, a barplot of the dataset to gain some intuition:\n",
"\n",
"\n",
"The first cell type increases from the control to the case category,\n",
"while the others behave the same (slightly decrease).\n",
"This decrease is due to compositional effects and should not be picked up as significant by a statistical method\n"
],
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": 30,
"outputs": [
{
"data": {
"text/plain": "<Figure size 432x288 with 1 Axes>",
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAc0AAAEICAYAAAA9YK8aAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAi30lEQVR4nO3de3xU5b3v8c8vCYQoCOFq5CKoAUUR2US0thyrVQvbij3UrUVtbLctL2Wr1WqtPdRL8dANle4qXqoUb1FP1VZUUKzVbm+tF8AdUQOEICoCAWLASCAGwvzOHzPBScxlBTKzJpnv+/WalzNrnlnzW3GY7zzPWutZ5u6IiIhI6zLCLkBERKSjUGiKiIgEpNAUEREJSKEpIiISkEJTREQkIIWmiIhIQAkLTTO7z8y2mNn7zTxvZjbXzNaY2btm9i+JqkVERKQ9JLKn+QAwoYXnJwL5sdtU4A9BVjphwgQHdNNNN910a9tN2kHCQtPdXwW2ttDkbKDIo94EeplZXmvr/fTTT9urRBERkTbJCvG9BwKfxD1eH1tW3t5vVHHOv7X3Kttdv7/8OewSRESkFR3iQCAzm2pmy8xsWUVFRdjliIhImgqzp7kBGBz3eFBs2Ve4+zxgHkBBQUGbx+bVixMRkfYQZmguBC4zs0eBE4Aqd2/3oVkREWna22+/3T8rK2s+cAwdZOQxwSLA+3V1dT8eO3bslqYaJCw0zexPwDeBvma2HrgR6ALg7ncDi4F/BdYAO4EfJaqW5vZpNtcDDaO9esMikmxZWVnzDz744KP69eu3LSMjI+2PsI1EIlZRUTFy06ZN84FJTbVJWGi6+5RWnnfgPxL1/iIi0qpjFJhfysjI8H79+lVt2rTpmObahDk8mzRt7cWlWnsRkQTJUGA2FPt7NDtUrTFsERGRgBSaIiLSbj755JOss846a9igQYNGHX300Ucdd9xxRxYVFfUKu672otAUEZF2EYlEOOuss44YP3589fr1698rKSlZ+fjjj6/95JNPusa32717d1gl7jeFpoiItItFixb16NKli1977bV7Z6EZPnz4runTp2+ZO3dun1NPPfWIE088cfhJJ500YvPmzZmnnXba4cOHDx85evToI996660cgJ/97GeH3HDDDQPqX5+fn390aWlp19LS0q7Dhg07etKkScMOO+ywoydMmHDY9u3bk55hCk0REWkX7733Xs6xxx67s7nnS0pKDnj66ac/WLp0aem11157yOjRo3euXr16xc0337zhoosuGtba+j/66KNul1122Za1a9eW9OjRI3LLLbf0a98taF1aHD176f1Lmlz+hx+NS5n2zbUVEemofvCDHwxZsmRJ9y5duvjUqVO3jB8//vMBAwbsAViyZEmPJ554Yg3ApEmTtk+dOjVr69atLXbkDj744F1nnHHGjti6K+fOndsf2JzwDYmjnqaIiLSLUaNG1bz77rsH1D9+6KGH1r388surt23blgVwwAEHRFpbR1ZWlkciXzarra21+vtm1qBt48fJkBY9zbb24lKtvYhIR3DWWWdtv/7662327Nn9fvGLX1QAVFdXN9k5O+GEE7bff//9fW655ZbyZ555pkdubm5d7969I0OHDq1dvHhxL4B//OMfB2zYsCG7/jXl5eVdX3zxxQNPO+20HY888kjvk046qTopGxZHPU0REWkXGRkZLFq06IPXXnutx8CBA0eNGjXqqAsvvHDoTTfdtL5x29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aXevcfdPiU5yPq6d31tEEiAr7AJEQlACnNPMcwb8p7vfs79v4u47zewFohcjPxcYG/904+bt+d4ikhjqaUo6+m8g28ym1i8ws2PNbDzRCff/PXZtTMxsoJn1D7je7UCPRsvmA3OBpe6+LW752WbWzcz6AN8kOtn5/ry3iCSBepqSdtzdzex/A7ea2S+AL4CPiF48uszMjgLeiB5kSzVwIbAlwKrfBfaY2XLgAXf/vbu/bWafA/c30fYloC9ws7tvBDbux3uLSBLoKiciCWRmhwAvA0e6eyS27Cag2t3nhFiaiOwDDc+KJIiZFQJvAdPrA1NEOjb1NEVERAJST1NERCQghaaIiEhACk0REZGAFJoiIiIBKTRFREQCUmiKiIgE9P8BVW2ngjGhpJIAAAAASUVORK5CYII=\n"
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"X = example_data.X\n",
"cell_types = example_data.var.index\n",
"obs = example_data.obs\n",
"\n",
"# Aggregate data by category\n",
"\n",
"count_df = pd.DataFrame(np.divide(X, np.sum(X, axis=1, keepdims=True)), columns=cell_types, index=obs.index).\\\n",
" merge(obs[\"x_0\"], left_index=True, right_index=True)\n",
"plot_df = pd.melt(count_df, id_vars=\"x_0\", var_name=\"Cell type\", value_name=\"count\")\n",
"\n",
"# barplot\n",
"d = sns.barplot(x=\"Cell type\", y=\"count\", hue=\"x_0\", data=plot_df,\n",
" palette='Blues')\n",
"\n",
"sns.scatterplot(x=plot_df.loc[plot_df[\"x_0\"]==0, \"Cell type\"].astype(\"float\")-0.2, y=\"count\", data=plot_df[plot_df[\"x_0\"]==0], color=\"black\", zorder=10, marker=\"o\")\n",
"sns.scatterplot(x=plot_df.loc[plot_df[\"x_0\"]==1, \"Cell type\"].astype(\"float\")+0.2, y=\"count\", data=plot_df[plot_df[\"x_0\"]==1], color=\"black\", zorder=10, marker=\"o\")\n",
"\n",
"loc, labels = plt.xticks()\n",
"\n",
"handles, labels = d.get_legend_handles_labels()\n",
"plt.legend(handles=handles, labels=[\"control\", \"case\"], loc='upper left', bbox_to_anchor=(1, 1), ncol=1, title=\"Group\")\n",
"\n",
"d.set(xlabel=\"Cell type\", ylabel=\"Proportion\", ylim=(0,1.01))\n",
"sns.despine()\n",
"\n",
"# manually add credible effects for each method (see below)\n",
"dashes=[(1,0), (4, 4), (7, 2, 2, 2)]\n",
"colors = ['#e41a1c','#377eb8','#4daf4a','#984ea3']\n",
"\n",
"plt.axhline(y = 1, xmin=0.04, xmax = 0.16, color=colors[0], dashes=dashes[0])\n",
"plt.axhline(y = 0.98, xmin=0.04, xmax = 0.16, color=colors[0], dashes=dashes[1])\n",
"plt.axhline(y = 0.94, xmin=0.04, xmax = 0.16, color=colors[1], dashes=dashes[1])\n",
"plt.axhline(y = 0.9, xmin=0.04, xmax = 0.16, color=colors[2], dashes=dashes[0])\n",
"plt.axhline(y = 0.86, xmin=0.04, xmax = 0.16, color=colors[2], dashes=dashes[2])\n",
"plt.axhline(y = 0.84, xmin=0.04, xmax = 0.16, color=colors[3], dashes=dashes[0])\n",
"plt.axhline(y = 0.82, xmin=0.04, xmax = 0.16, color=colors[3], dashes=dashes[1])\n",
"\n",
"plt.axhline(y = 0.88, xmin=0.44, xmax = 0.56, color=colors[2], dashes=dashes[0])\n",
"plt.axhline(y = 0.84, xmin=0.44, xmax = 0.56, color=colors[3], dashes=dashes[0])\n",
"plt.axhline(y = 0.82, xmin=0.44, xmax = 0.56, color=colors[3], dashes=dashes[1])\n",
"\n",
"plt.axhline(y = 0.84, xmin=0.24, xmax = 0.36, color=colors[3], dashes=dashes[0])\n",
"plt.axhline(y = 0.82, xmin=0.24, xmax = 0.36, color=colors[3], dashes=dashes[1])\n",
"\n",
"plt.axhline(y = 0.84, xmin=0.64, xmax = 0.76, color=colors[3], dashes=dashes[0])\n",
"plt.axhline(y = 0.84, xmin=0.84, xmax = 0.96, color=colors[3], dashes=dashes[0])\n",
"\n",
"plot_path = \"../../sccoda_benchmark_data/model_comparison/model_comparison_plots/\"\n",
"plt.savefig(plot_path + \"/model_comparison_example_data_grouped_v2.svg\", format=\"svg\", bbox_inches=\"tight\")\n",
"plt.savefig(plot_path + \"/model_comparison_example_data_grouped_v2.png\", format=\"png\", bbox_inches=\"tight\")\n",
"\n",
"plt.show()"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n"
}
}
},
{
"cell_type": "code",
"execution_count": 2,
Expand Down

0 comments on commit 15b5f4a

Please sign in to comment.