Hi, I am relatively new to R so apologies if the code/question is not in the right format! I will to improve! I am trying to perform enrichment analysis with reactomePA (R package) on a smaller list of genes (477) and I have a problem with organizing the dataset. As far as I understood the input file should contain only two-column: Entrez ID (column n.1) and fold change (column n.2). I converted the ensemble ID with Biomart with the online tool, and then created a new file with ID and FC. My dataset:
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
# A tibble: 6 x 2
Entrezgene_ID log2fc
<chr> <dbl>
1 14 -1.02
2 80755 -1.45
3 60496 -1.17
4 6059 -1.48
5 10061 -1.35
6 10006 -1.51
Then I was trying to following this code:
#load packages
library(org.Hs.eg.db)
library(DOSE)
library(ReactomePA)
## feature 1: numeric vector
geneList <- d[,2]
## feature 2: named vector
names(geneList) <- as.character(d[,1])
print(geneList)
## feature 3: decreasing order
geneLIST <- sort(geneList, decreasing = TRUE)
head(geneList)
But when I try to name the vector I obtain with a list of entrez ID separated by comma and no FC (geneList: 477 obs, 1 variable c ("14", "80755",... and so on). I was expecting to found then in rows next to the fold change, Am I wrong? and of course, if I try to run to organize in decreasing order ( "feature 3") I got this error because I have basically a list of number included in the " " not associated with any numbers :
> <error/vctrs_error_subscript_oob> Can't subset columns that don't
> exist. x Locations 141, 373, 119, 229, 230, etc. don't exist. i There
> are only 1 column. Backtrace:
> 1. base::sort(geneList, decreasing = TRUE)
> 15. vctrs:::stop_subscript_oob(...)
> 16. vctrs:::stop_subscript(...)
and this is the traceback () output when I try to perform the "feature 3" (due I guess to the error in naming the vector:
> 15: stop(fallback) 14: rlang:::signal_abort(x) 13: cnd_signal(cnd) 12:
> value[[3L]](cond) 11: tryCatchOne(expr, names, parentenv,
> handlers[[1L]]) 10: tryCatchList(expr, classes, parentenv, handlers)
> 9: tryCatch(force(expr), vctrs_error_subscript = function(cnd) {
> cnd$subscript_arg <- j_arg
> cnd$subscript_elt <- "column"
> if (isTRUE(assign) && !isTRUE(cnd$subscript_action %in% c("negate"))) {
> cnd$subscript_action <- "assign"
> }
> cnd_signal(cnd) }) 8: subclass_col_index_errors(vec_as_location(j, n, names, arg =
> as_label(j_arg)),
> j_arg = j_arg, assign = assign) 7: vectbl_as_col_location(j, length(x), names(x), j_arg = j_arg,
> assign = assign) 6: vectbl_as_col_index(j, x, j_arg = j_arg) 5: tbl_subset_col(x, j = j, j_arg) 4: `[.tbl_df`(x, order(x, na.last =
> na.last, decreasing = decreasing)) 3: x[order(x, na.last = na.last,
> decreasing = decreasing)] 2: sort.default(geneList, decreasing = TRUE)
> 1: sort(geneList, decreasing = TRUE)
Can someone help me? Thank you for your time! Camilla