Skip to content

Commit c1f908c

Browse files
author
Jonas Ohlsson
committed
use R-style syntax.
1 parent 11e2fc9 commit c1f908c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

rna_seq.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ library(gageData)
217217
Let’s use the `mapIds` function to add more columns to the results. The row.names of our results table has the Ensembl gene ID (our key), so we need to specify `keytype=ENSEMBL`. The column argument tells the `mapIds` function which information we want, and the `multiVals` argument tells the function what to do if there are multiple possible values for a single input value. Here we ask to just give us back the first one that occurs in the database. Let’s get the Entrez IDs, gene symbols, and full gene names.
218218

219219
```R
220-
res$symbol = mapIds(org.Hs.eg.db,
220+
res$symbol <- mapIds(org.Hs.eg.db,
221221
keys=row.names(res),
222222
column="SYMBOL",
223223
keytype="ENSEMBL",
224224
multiVals="first")
225-
res$entrez = mapIds(org.Hs.eg.db,
225+
res$entrez <- mapIds(org.Hs.eg.db,
226226
keys=row.names(res),
227227
column="ENTREZID",
228228
keytype="ENSEMBL",
229229
multiVals="first")
230-
res$name = mapIds(org.Hs.eg.db,
230+
res$name <- mapIds(org.Hs.eg.db,
231231
keys=row.names(res),
232232
column="GENENAME",
233233
keytype="ENSEMBL",
@@ -243,16 +243,16 @@ The gageData package has pre-compiled databases mapping genes to KEGG pathways a
243243
```R
244244
data(kegg.sets.hs)
245245
data(sigmet.idx.hs)
246-
kegg.sets.hs = kegg.sets.hs[sigmet.idx.hs]
246+
kegg.sets.hs <- kegg.sets.hs[sigmet.idx.hs]
247247
head(kegg.sets.hs, 3)
248248
```
249249

250250
Run the pathway analysis. See help on the gage function with `?gage`. Specifically, you might want to try changing the value of same.dir.
251251

252252
```R
253-
foldchanges = res$log2FoldChange
254-
names(foldchanges) = res$entrez
255-
keggres = gage(foldchanges, gsets=kegg.sets.hs, same.dir=TRUE)
253+
foldchanges <- res$log2FoldChange
254+
names(foldchanges) <- res$entrez
255+
keggres <- gage(foldchanges, gsets=kegg.sets.hs, same.dir=TRUE)
256256
lapply(keggres, head)
257257
```
258258

@@ -262,29 +262,29 @@ Pull out the top 5 upregulated pathways, then further process that just to get t
262262
library(dplyr)
263263

264264
# Get the pathways
265-
keggrespathways = data.frame(id=rownames(keggres$greater), keggres$greater) %>%
265+
keggrespathways <- data.frame(id=rownames(keggres$greater), keggres$greater) %>%
266266
tbl_df() %>%
267267
filter(row_number()<=5) %>%
268268
.$id %>%
269269
as.character()
270270
keggrespathways
271271

272272
# Get the IDs.
273-
keggresids = substr(keggrespathways, start=1, stop=8)
273+
keggresids <- substr(keggrespathways, start=1, stop=8)
274274
keggresids
275275
```
276276

277277
Finally, the `pathview()` function in the pathview package makes the plots. Let’s write a function so we can loop through and draw plots for the top 5 pathways we created above.
278278

279279
```R
280280
# Define plotting function for applying later
281-
plot_pathway = function(pid) pathview(gene.data=foldchanges, pathway.id=pid, species="hsa", new.signature=FALSE)
281+
plot_pathway <- function(pid) pathview(gene.data=foldchanges, pathway.id=pid, species="hsa", new.signature=FALSE)
282282

283283
# Unload dplyr since it conflicts with the next line
284284
detach("package:dplyr", unload=T)
285285

286286
# plot multiple pathways (plots saved to disk and returns a throwaway list object)
287-
tmp = sapply(keggresids, function(pid) pathview(gene.data=foldchanges, pathway.id=pid, species="hsa"))
287+
tmp <- sapply(keggresids, function(pid) pathview(gene.data=foldchanges, pathway.id=pid, species="hsa"))
288288
```
289289

290290
#### Thanks

0 commit comments

Comments
 (0)