natverse / nat

NeuroAnatomy Toolbox: An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons.
https://natverse.org/nat/
62 stars 26 forks source link

Allow xyzmatrix method to assign by rownames #469

Open dokato opened 3 years ago

dokato commented 3 years ago

When I try to assign soma positions to neurolist metadata with xyzmatrix I get only this warning

> xyzmatrix(dps5[,]) <- xyzmatrix(meta)
Warning message:
In matrix(value, n, p) :
  data length [21] is not a sub-multiple or multiple of the number of rows [5]

that results in completely messed up values. See toy data to reproduce.

example.rda.zip

Expected

xyzmatrix recognizes and assigns positions based on rownames of a larger set of neuron body ids from the RHS.

Probably a new xyzmatrix <-matrix` function needed here?

jefferis commented 3 years ago

Hmm. That is not something I have tried to do in the past. I guess it would be convenient in this scenario, but I wonder if at some point it might be a little fragile. This method will not know that it is a neuronlist attached data.frame, it could be any old data.frame or matrix and we use it a lot in that more general context.