Help with karyoploteR
0
0
Entering edit mode
11 weeks ago
Alex • 0

Hellow there. I'm new in the bioinformatics and programmigs. I'm trying to follow this example (link:GeneExpression) and everything was going well, but I get the error at this step:

mcols(dm.genes) <- res[names(dm.genes), c("log2FoldChange", "stat", "pvalue", "padj")]

In my case I get this:

mcols(dm.genes) <- res[names(dm.genes), c("log2FoldChange", "stat", "pvalue", "padj")]
Error: subscript contains invalid names

What can the error be related to and how to fix it?

visualisation R karyoploteR • 292 views
ADD COMMENT
1
Entering edit mode

try print dm.genes firstly and see if the column names in the dataframe of dm.genes matches the vector c("log2FoldChange", "stat", "pvalue", "padj")

ADD REPLY
1
Entering edit mode

To give a bit more context: the error message indicates that you're asking for rows (via names(dm.genes)) or columns (via c("log2FoldChange", "stat", "pvalue", "padj") that aren't part of the data.frame res. To pinpoint the issue, you need to figure out which entries of your subset are missing from res (or are named differently, even if a column is named Padj, it won't be recognized if you try to subset via padj)

  • all(names(dm.genes) %in% rownames(res) will tell you if there are gene names in your dm.genes object that aren't part of the rownames of res (if all are found, the result should be TRUE)
  • you can use the same strategy for the columns: all(c("log2FoldChange", "stat", "pvalue", "padj") %in% colnames(res))
  • if you want to know which entries are causing the error, you can, for example, do:
    found <- names(dm.genes) %in% rownames(res) # should be a vector of TRUE/FALSE
    ## return the names which are not found in the rownames
    names(dm.genes)[!found] # note the exclamation mark, which is the logical NOT operator
    
ADD REPLY
0
Entering edit mode

Thank you so much! I get it

ADD REPLY

Login before adding your answer.

Traffic: 1032 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6