This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with karyoploteR

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

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")

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
    

Thank you so much! I get it

0 answers

No answers yet.

Log in to answer this question.