Skip to content

Commit ef55c25

Browse files
Add files via upload
Add bonus notebook to run new datasets.
1 parent 939b6bc commit ef55c25

1 file changed

Lines changed: 240 additions & 0 deletions

File tree

Bonus_Notebook_new_data.ipynb

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "6eb2c6fb-13d9-4461-ad74-44262079211c",
6+
"metadata": {},
7+
"source": [
8+
"# MDIBL Transcriptome Assembly Learning Module\n",
9+
"# Bonus notebook: Using TransPi on a new dataset"
10+
]
11+
},
12+
{
13+
"cell_type": "markdown",
14+
"id": "c38bba56-40d9-4ca4-b58b-b9733b424b1f",
15+
"metadata": {},
16+
"source": [
17+
"In this notebook, we are going to explore how to run this module with a new dataset. These submodules provide a great framework for running a rigorous and scalable transcriptome assembly, but there are some considerations that must be made in order to run this with your own data. We will walk through that process here so that hopefully, you are able to take these notebooks to your research group and use them for your own analysis."
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"id": "80044322-a021-4fdc-ad83-504961bd1919",
23+
"metadata": {},
24+
"source": [
25+
"The data we are using here comes from SRA. In this example, we are using data from an experiment that compared RNA sequences in honeybees with and without viral infections. The BioProject ID is [PRJNA274674](https://www.ncbi.nlm.nih.gov/bioproject/PRJNA274674). This experiment includes 6 RNA-seq samples and 2 methylation-seq samples. We are only considering the RNA-seq data here. Additionally, we have subsampled them to about 2 millions reads collectively accross all of the samples. In a real analysis this would not be a good idea, but to keep costs and runtimes low we will use the down-sampled files in this demonstration. If you want to explore the full dataset, we recommend pulling the fastq files using the [STRIDES tutorial on SRA downloads](https://github.com/STRIDES/NIHCloudLabGCP/blob/main/tutorials/notebooks/SRADownload/SRA-Download.ipynb). As with the original example in this module, we have concatenated all 6 files into one set of combined fastq files called apis_joined_R{1,2}.fastq.gz We have stored the subsampled fastq files in this module's cloud storage bucket."
26+
]
27+
},
28+
{
29+
"cell_type": "markdown",
30+
"id": "dcf2a2d0-bc91-4a2a-9db0-62f1eee91f92",
31+
"metadata": {},
32+
"source": [
33+
"Before we start any analysis, let's set up the environment just like we did in Submodule_01 and Submodule_02 where we move to the correct directory and install software."
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"id": "795e3329-21d8-4de0-91c4-58c81371a712",
40+
"metadata": {
41+
"tags": []
42+
},
43+
"outputs": [],
44+
"source": [
45+
"%cd /home/jupyter"
46+
]
47+
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"id": "c9701541-9c05-4a02-abe7-e1126826efe3",
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
55+
"!pwd"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"id": "2d0c3012-27ca-4eb7-a106-6532f62cbc82",
62+
"metadata": {},
63+
"outputs": [],
64+
"source": [
65+
"#update java\n",
66+
"!sudo apt update\n",
67+
"!sudo apt-get install default-jdk -y\n",
68+
"!java -version"
69+
]
70+
},
71+
{
72+
"cell_type": "code",
73+
"execution_count": null,
74+
"id": "3d6ffb05-19bb-42c4-a628-6d874c5d3517",
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"# install mamba and dependencies\n",
79+
"!curl -L -O https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh\n",
80+
"!bash Mambaforge-$(uname)-$(uname -m).sh -b -p $HOME/mambaforge\n",
81+
"!~/mambaforge/bin/mamba install -c bioconda sra-tools perl-dbd-sqlite perl-dbi -y"
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"id": "21ae7ca3-c9e1-4160-a29f-37a53b8265ab",
88+
"metadata": {},
89+
"outputs": [],
90+
"source": [
91+
"#install Nextflow\n",
92+
"!curl https://get.nextflow.io | bash\n",
93+
"!chmod +x nextflow\n",
94+
"!./nextflow self-update"
95+
]
96+
},
97+
{
98+
"cell_type": "code",
99+
"execution_count": null,
100+
"id": "f7d6f314-9af1-428f-85ea-6d02e527a6a1",
101+
"metadata": {},
102+
"outputs": [],
103+
"source": [
104+
"# Copy the software from the storage bucket\n",
105+
"!gsutil -m cp -r gs://nigms-sandbox/nosi-inbremaine-storage/TransPi ./"
106+
]
107+
},
108+
{
109+
"cell_type": "code",
110+
"execution_count": null,
111+
"id": "e5bdc3fa-7b78-4329-ae17-49ffce2085bb",
112+
"metadata": {},
113+
"outputs": [],
114+
"source": [
115+
"# Copy the data from the storage bucket\n",
116+
"!gsutil -m cp -r gs://nigms-sandbox/nosi-inbremaine-storage/resources ./"
117+
]
118+
},
119+
{
120+
"cell_type": "code",
121+
"execution_count": null,
122+
"id": "65350b31-588b-42d9-90b4-849a523be021",
123+
"metadata": {},
124+
"outputs": [],
125+
"source": [
126+
"#Make the program executable\n",
127+
"!chmod -R +x ./TransPi/bin"
128+
]
129+
},
130+
{
131+
"cell_type": "markdown",
132+
"id": "15d79bb0-9f4c-469a-b2e6-3379e68f8f73",
133+
"metadata": {},
134+
"source": [
135+
"Let's have a look at what we've downloaded to make sure it's there."
136+
]
137+
},
138+
{
139+
"cell_type": "code",
140+
"execution_count": null,
141+
"id": "9c5606e2-5c0c-423c-9e32-40bd550c19cb",
142+
"metadata": {
143+
"tags": []
144+
},
145+
"outputs": [],
146+
"source": [
147+
"!ls ./resources/seq2"
148+
]
149+
},
150+
{
151+
"cell_type": "markdown",
152+
"id": "08ae572a-fe6d-4852-a11c-5a2449c1d6b2",
153+
"metadata": {},
154+
"source": [
155+
"You should see the apis_joined fastq files alongside the others that we use in the previous submodules. Now let's adjust the workflow to run on them."
156+
]
157+
},
158+
{
159+
"cell_type": "markdown",
160+
"id": "331a3857-7734-41e4-819a-de3603b9c95b",
161+
"metadata": {},
162+
"source": [
163+
"One of the great benefits of using a workflow manager like Nextflow is that it allows easy swapping of input samples without drastic changes to the code. In the true spirit of reproducible workflows, the only change necessary in order to run the apis samples is to adjust the `reads` line in the `nextflow.config` file `params` section to point to the new reads location. We show this below."
164+
]
165+
},
166+
{
167+
"cell_type": "markdown",
168+
"id": "c22622e3-56a7-42bb-9884-abd39c72d6e3",
169+
"metadata": {},
170+
"source": [
171+
"```\n",
172+
"// Directory for reads\n",
173+
"reads=\"/home/jupyter/resources/seq2/apis_joined*R[1,2].fastq.gz\"\n",
174+
"```"
175+
]
176+
},
177+
{
178+
"cell_type": "markdown",
179+
"id": "fd94aacc-2fb8-4a99-8378-2883b723253a",
180+
"metadata": {},
181+
"source": [
182+
"After this change, you should be able to run the same Nextflow command as you did in Submodule_02 and everything will progress automatically."
183+
]
184+
},
185+
{
186+
"cell_type": "code",
187+
"execution_count": null,
188+
"id": "24663040-553b-4434-83a8-93fb9d2fd58f",
189+
"metadata": {},
190+
"outputs": [],
191+
"source": [
192+
"!NXF_VER=22.10.1 ./nextflow run ./TransPi/TransPi.nf \\\n",
193+
"-profile docker --k 17,25,43 --maxReadLen 50 --all "
194+
]
195+
},
196+
{
197+
"cell_type": "markdown",
198+
"id": "57dc8622-fb61-4ce6-ad40-48fc710a4713",
199+
"metadata": {},
200+
"source": [
201+
"With the subsampled reads, the assembly should complete in about 2 hours using a n1-highmem-16 machine."
202+
]
203+
},
204+
{
205+
"cell_type": "code",
206+
"execution_count": null,
207+
"id": "a822011a-4d77-4d99-8124-67ecb8f3dacf",
208+
"metadata": {},
209+
"outputs": [],
210+
"source": []
211+
}
212+
],
213+
"metadata": {
214+
"environment": {
215+
"kernel": "python3",
216+
"name": "common-cpu.m113",
217+
"type": "gcloud",
218+
"uri": "gcr.io/deeplearning-platform-release/base-cpu:m113"
219+
},
220+
"kernelspec": {
221+
"display_name": "Python 3",
222+
"language": "python",
223+
"name": "python3"
224+
},
225+
"language_info": {
226+
"codemirror_mode": {
227+
"name": "ipython",
228+
"version": 3
229+
},
230+
"file_extension": ".py",
231+
"mimetype": "text/x-python",
232+
"name": "python",
233+
"nbconvert_exporter": "python",
234+
"pygments_lexer": "ipython3",
235+
"version": "3.10.13"
236+
}
237+
},
238+
"nbformat": 4,
239+
"nbformat_minor": 5
240+
}

0 commit comments

Comments
 (0)