Skip to content

Commit d44d448

Browse files
authored
Merge pull request #33 from biosustain/add_PXD070899
Add pxd070899
2 parents 4e52989 + c05bdf7 commit d44d448

11 files changed

Lines changed: 4037 additions & 21 deletions

File tree

.devcontainer/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ one in this project, so if things break, have a look there.
88

99
The devcontainer uses the
1010
[`nextflow-io/training` container](https://github.com/nextflow-io/training/pkgs/container/training)
11-
from GitHub Container Registry, as provided by the nextflow team. I copied the
11+
from GitHub Container Registry, as provided by the nextflow team. The
1212
[Dockerfile](https://github.com/biosustain/dsp_course_proteomics_intro/blob/HEAD/.devcontainer/Dockerfile)
13-
which was used to build the container image `2.1.7` for reference of what the container contains.
13+
extends this image with some additional software, e.g. for the downstream data analysis, and is built
14+
and published to the GitHub Container Registry using an action.
1415

15-
The Dockerimage is published based on a devcontainer configuration file in the nextflow training repo,
16-
[`.devcontainer/codespaces-dev/devcontainer.json`](https://github.com/nextflow-io/training/blob/master/.devcontainer/codespaces-dev/devcontainer.json)
17-
and then published to the GitHub Container Registry using an action.
16+
The devcontainer then uses this image, see,
17+
[`.devcontainer/codespaces-dev/devcontainer.json`](https://github.com/nextflow-io/training/blob/master/.devcontainer/codespaces-dev/devcontainer.json).
1818

1919
## Additional software
2020

3_data_analysis_PXD070899.ipynb

Lines changed: 272 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,272 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "823dca58",
6+
"metadata": {},
7+
"source": [
8+
"# Exercise: Data Analysis PXD070899\n",
9+
"\n",
10+
"Plan\n",
11+
"- read data and log2 transform intensity values\n",
12+
"- aggregate peptide intensities to protein intensities\n",
13+
"- format data from long to wide format\n",
14+
"- remove contaminant proteins\n",
15+
"- check for missing values\n",
16+
"- Clustermap of sample and proteins\n",
17+
"- differential analysis (Volcano Plots)\n",
18+
"- Enrichment Analysis\n",
19+
"- check for maltose update pathway (Fig. 3 in paper)"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"id": "3206180f",
26+
"metadata": {
27+
"tags": [
28+
"hide-output"
29+
]
30+
},
31+
"outputs": [],
32+
"source": [
33+
"%pip install acore vuecore \"pingouin<0.6.0\""
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"id": "9aad124f",
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"from pathlib import Path\n",
44+
"\n",
45+
"import acore.differential_regulation\n",
46+
"import acore.enrichment_analysis\n",
47+
"import acore.normalization\n",
48+
"import matplotlib.pyplot as plt\n",
49+
"import numpy as np\n",
50+
"import pandas as pd\n",
51+
"import plotly.express as px\n",
52+
"import scipy.stats\n",
53+
"import seaborn as sns\n",
54+
"import vuecore\n",
55+
"from acore.io.uniprot import fetch_annotations, process_annotations\n",
56+
"from vuecore.viz import get_enrichment_plots"
57+
]
58+
},
59+
{
60+
"cell_type": "markdown",
61+
"id": "cabfd7c2",
62+
"metadata": {},
63+
"source": [
64+
"# Paramters\n",
65+
"- `file_in`: input file with the quantified peptide data in MSstats format\n",
66+
" as provided by quantms\n",
67+
"- `out_dir`: output directory for the results of the data analysis, \n",
68+
" which will be used later for the report generation with VueGen.\n",
69+
"\n",
70+
"The file will be loaded from the online repository if it is not present."
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"id": "b503b660",
77+
"metadata": {
78+
"tags": [
79+
"parameters"
80+
]
81+
},
82+
"outputs": [],
83+
"source": [
84+
"file_in: str = Path(\n",
85+
" \"data/PXD070899/processed/report.pg_matrix.tsv\"\n",
86+
") # input file with the quantified peptide data in MSstats format as provided by quantms\n",
87+
"out_dir = \"data/PXD070899/report/\" # output directory for the results of the data analysis, which will be used later for the report generation with VueGen.\n",
88+
"min_obs_per_group:int = 3 # minimum number of observations per group for a protein to be included in the differential regulation analysis"
89+
]
90+
},
91+
{
92+
"cell_type": "markdown",
93+
"id": "fa6869d2",
94+
"metadata": {},
95+
"source": [
96+
"Create output directory if it does not exist"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"id": "dbe29342",
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"out_dir = Path(out_dir)\n",
107+
"out_dir.mkdir(parents=True, exist_ok=True)\n",
108+
"print(f\"Output directory: {out_dir}\")"
109+
]
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"id": "6f757866",
114+
"metadata": {},
115+
"source": [
116+
"We have the following columns in the data:"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": null,
122+
"id": "06f54aee",
123+
"metadata": {},
124+
"outputs": [],
125+
"source": [
126+
"if not file_in.exists():\n",
127+
" file_in = (\n",
128+
" \"https://raw.githubusercontent.com/biosustain/dsp_course_proteomics_intro/HEAD\"\n",
129+
" \"/data/PXD070899/processed/report.pg_matrix.tsv\"\n",
130+
" )\n",
131+
"df = pd.read_csv(file_in, sep=\"\\t\", header=0, index_col=0) # .set_index([])\n",
132+
"df.head()"
133+
]
134+
},
135+
{
136+
"cell_type": "markdown",
137+
"id": "c836978a",
138+
"metadata": {},
139+
"source": [
140+
"Potentiall clean filepath names in DIANN output"
141+
]
142+
},
143+
{
144+
"cell_type": "code",
145+
"execution_count": null,
146+
"id": "a83ac030",
147+
"metadata": {},
148+
"outputs": [],
149+
"source": [
150+
"df.columns = df.columns.str.split(r\"/|\\\\\").str[-1]\n",
151+
"df.head()"
152+
]
153+
},
154+
{
155+
"cell_type": "markdown",
156+
"id": "f46b47ea",
157+
"metadata": {},
158+
"source": [
159+
"The first 6 columns contain the meta information about the peptides, \n",
160+
"while the remaining columns contain the intensities."
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": null,
166+
"id": "9fd0ea35",
167+
"metadata": {},
168+
"outputs": [],
169+
"source": [
170+
"proteins_meta = df.iloc[:,:5]\n",
171+
"proteins_meta "
172+
]
173+
},
174+
{
175+
"cell_type": "code",
176+
"execution_count": null,
177+
"id": "038374d1",
178+
"metadata": {},
179+
"outputs": [],
180+
"source": [
181+
"proteins = df.iloc[:,5:].T\n",
182+
"proteins.index.name = \"SampleID\"\n",
183+
"proteins.columns.name = \"ProteinName\"\n",
184+
"proteins.head()"
185+
]
186+
},
187+
{
188+
"cell_type": "markdown",
189+
"id": "d4a33fd1",
190+
"metadata": {},
191+
"source": [
192+
"Log2 transform the intensity values and remove contaminant proteins"
193+
]
194+
},
195+
{
196+
"cell_type": "code",
197+
"execution_count": null,
198+
"id": "23a805ed",
199+
"metadata": {},
200+
"outputs": [],
201+
"source": [
202+
"to_drop = proteins.filter(regex=\"cRAP-|CON_\", axis=1).columns\n",
203+
"to_drop"
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"id": "b5190a90",
210+
"metadata": {},
211+
"outputs": [],
212+
"source": [
213+
"proteins = np.log2(proteins).drop(to_drop, axis=1)\n",
214+
"proteins"
215+
]
216+
},
217+
{
218+
"cell_type": "markdown",
219+
"id": "3477e9a4",
220+
"metadata": {
221+
"lines_to_next_cell": 2
222+
},
223+
"source": [
224+
"Add label encoding"
225+
]
226+
},
227+
{
228+
"cell_type": "code",
229+
"execution_count": null,
230+
"id": "99b01cb0",
231+
"metadata": {
232+
"lines_to_next_cell": 0
233+
},
234+
"outputs": [],
235+
"source": [
236+
"# label_encoding = {\"WT\": 0, \"AYa2022\": 1, \"AYa18\": 2, \"AY\": 3}\n",
237+
"label_suf = pd.Series(\n",
238+
" proteins.index.str.split(\"_\").str[-2],\n",
239+
" index=proteins.index,\n",
240+
" name=\"condition\",\n",
241+
")\n",
242+
"label_suf"
243+
]
244+
},
245+
{
246+
"cell_type": "markdown",
247+
"id": "750467e3",
248+
"metadata": {},
249+
"source": [
250+
"# Homework\n",
251+
"Repeat the analysis based on the tutorial from the course.\n",
252+
"\n",
253+
"> Small adjustments are needed.\n",
254+
"\n",
255+
"- copy bit by bit"
256+
]
257+
}
258+
],
259+
"metadata": {
260+
"jupytext": {
261+
"cell_metadata_filter": "tags,-all",
262+
"formats": "ipynb,py:percent"
263+
},
264+
"kernelspec": {
265+
"display_name": "base",
266+
"language": "python",
267+
"name": "python3"
268+
}
269+
},
270+
"nbformat": 4,
271+
"nbformat_minor": 5
272+
}

0 commit comments

Comments
 (0)