0

Sorry for the poor wording, I'm hoping to change the name of an internal variable in a dgCMatrix. Specifically I want to change "Dimnames" to "dimnames" (I've attached a picture of the object variables for clarity), as I believe that may help with an error I'm getting (I'll post that at the bottom).

I've tried this, but to no avail

rename(emat@Dimnames, "dimnames")

Here is the object, hoping to change "Dimnames" to "dimnames"

The error I hope to fix with this:

> rvel.cd <- gene.relative.velocity.estimates(emat,nmat,deltaT=2,
+                                             kCells=10,
+                                             cell.dist=cell.dist,
+                                             fit.quantile=fit.quantile,
+                                             n.cores=2)
matching cells between cell.dist and emat/nmat ... done
calculating cell knn ... done
calculating convolved matrices ... Error in intI(i, n = d[1], dn[[1]], give.dn = FALSE) : 
  no 'dimnames[[.]]': cannot use character indexing

Reproducible data:

#Generate dgCMatrix
library(Matrix)
i <- c(1,3:8)
j <- c(2,9,6:10)
x <- 7 * (1:7)
emat <- sparseMatrix(i, j, x = x)
  • 2
    It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. But why would you want to rename an internal name for an object? That will probably break the behavior of the object. What are you really trying to accomplish? – MrFlick Oct 16 '19 at 14:46
  • 1
    What MrFlick said. Also: When using packages please state what package you are using. `gene.relative.velocity.estimates` is certainly not base R and seems to stem from a package that is not even on CRAN. – Bernhard Oct 16 '19 at 14:53
  • Thanks for the input, I've added some code to make a simple dgCMatrix which at least is reproducible sample data. That's my shortcoming, I didn't realise the object's names were so rigid. The reason I'm trying to change it is the error that the package gene.relative.velocity.estimates generates implies it's looking for "dimnames" in the object, where it is actually "Dimnames". – Gordon Beattie Oct 16 '19 at 15:01
  • My apologies Bernhard, not knowing that the objects internal names were rigid I presumed it would be a simple case of changing the name, so I just added the reasoning for some context. But yes, if it's not possible to change "Dimnames" I may have to focus on the package itself – Gordon Beattie Oct 16 '19 at 15:03

0 Answers0