You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
names of wavelength vector are lost while collapsing two hyperSpec objects #87
Mass 1 Mass 2 Mass 3 Mass 4 Mass 5 Mass 6 Mass 7 Mass 8 Mass 9 Mass 10 Mass 11 Mass 12 Mass 13 Mass 14 Mass 15 Mass 16 Mass 17 Mass 18 Mass 19
160.90 158.85 147.00 140.90 133.05 130.90 119.95 119.15 118.05 116.95 112.90 106.00 105.10 98.95 96.95 91.00 85.05 83.05 77.00
Mass 20 Mass 21 Mass 22 Mass 23 Mass 24 Mass 25 Mass 26 Mass 27 Mass 28 Mass 29 Mass 30 Mass 31 Mass 32 Mass 33 Mass 34 Mass 35 Mass 36 Mass 37
71.90 71.10 70.00 69.00 57.10 56.10 55.00 43.85 43.05 41.10 40.10 39.00 32.15 31.15 30.05 29.05 28.15 27.05
wl (object2)
Mass 1 Mass 2 Mass 3 Mass 4 Mass 5 Mass 6 Mass 7 Mass 8 Mass 9 Mass 10 Mass 11 Mass 12 Mass 13 Mass 14 Mass 15 Mass 16 Mass 17 Mass 18 Mass 19
160.90 158.85 147.00 140.90 133.05 130.90 119.95 119.15 118.05 116.95 112.90 106.00 105.10 98.95 96.95 91.00 85.05 83.05 77.00
Mass 20 Mass 21 Mass 22 Mass 23 Mass 24 Mass 25 Mass 26 Mass 27 Mass 28 Mass 29 Mass 30 Mass 31 Mass 32 Mass 33 Mass 34 Mass 35 Mass 36 Mass 37
71.90 71.10 70.00 69.00 57.10 56.10 55.00 43.85 43.05 41.10 40.10 39.00 32.15 31.15 30.05 29.05 28.15 27.05
As can be seen, the naming of the vector elements is gone.
These named vectors might also be useful while collapsing to identify wavelengths, which should be collapsed into one single wavelength in the new object.
I'm currently overhauling collapse to fix issues #81 and #69.
I'm not sure how this issue could/should be sensibly tackled:
First of all, note that for the provided example, rbind would do what is required.
The purpose of collapse is to merge hyperSpec objects with differing wavelength vectors, including to "bin" wavelengths that are almost equal (numerically). This includes that even the resulting wavelengths may not be exactly equal to any of the wavelengths of the collapsed objects.
Up to now, the resulting wavelengths are the centers of the wavelength bins indicated by wl.tolerance and the "destroyed" column names are the bin numbers. (Exact behaviour will change with the current overhauling, though.)
The question how to preserve column names is not straightforward in such a general way. Consider:
> wl (object1) %>% head
Mass 1 Mass 2 Mass 3 Mass 4 Mass 5 Mass 6
160.90 158.85 147.00 140.90 133.05 130.90
> wl (object2) %>% head
Mass 1 Mass 2 Mass 3 Mass 4 Mass 5 Mass 6
158.85 140.90 132.95 131.00 120.05 119.05
The same difficulties may happen with the column names of $spc.
The same wavelength is named Mass 2 in object1 but Mass 1 in object2; also object1Mass 4 and object2 but Mass 2 are the same (and so on). How should the resulting wavelengths (and columns of $spc) be named?
Wavelengths of object1Mass 3 and object2Mass 3 are different, so will end up in different columns of the resulting spectra matrix. Shall the result have multiple wavelengths and columns in $spc with the same name?
What would be relatively easy to implement is to take the names of @wavelength and the columns of $spc from the first object that has the respective wavelength.
Activity
GegznaV commentedon Apr 17, 2019
Some time ago I faced a similar issue.
galaxismad commentedon Jun 18, 2019
Collapse also "destroys" the column names of the spectra matrix (in $spc).
head (colnames (chondro$spc))[1] "602" "606" "610" "614" "618" "622"after collapsing, there are some weird numbers
head(colnames(collapse (chondro, chondro)$spc))[1] "40399536128" "40667971584" "40936407040" "41204842496" "41473277952" "41741713408"cbeleites commentedon Dec 17, 2019
I'm currently overhauling
collapseto fix issues #81 and #69.I'm not sure how this issue could/should be sensibly tackled:
First of all, note that for the provided example,
rbindwould do what is required.The purpose of
collapseis to merge hyperSpec objects with differing wavelength vectors, including to "bin" wavelengths that are almost equal (numerically). This includes that even the resulting wavelengths may not be exactly equal to any of the wavelengths of the collapsed objects.Up to now, the resulting wavelengths are the centers of the wavelength bins indicated by
wl.toleranceand the "destroyed" column names are the bin numbers. (Exact behaviour will change with the current overhauling, though.)The question how to preserve column names is not straightforward in such a general way. Consider:
we have
The same difficulties may happen with the column names of
$spc.Mass 2inobject1butMass 1inobject2; alsoobject1Mass 4andobject2butMass 2are the same (and so on).How should the resulting wavelengths (and columns of
$spc) be named?object1Mass 3andobject2Mass 3are different, so will end up in different columns of the resulting spectra matrix.Shall the result have multiple wavelengths and columns in
$spcwith the same name?What would be relatively easy to implement is to take the names of
@wavelengthand the columns of$spcfrom the first object that has the respective wavelength.MAJOR overhaul of collapse(). wl.tolerance now has clear interpretati…
cbeleites commentedon Dec 17, 2019
First issue (names of
@wavelength) implemented as suggested above.The 2nd issue (weird column names in $spc) is actually a separate issue: Collapse also "destroys" the column names of the spectra matrix (in $spc). #89
The column names of $spc should be wavelengths (to be consistent with documented behaviour of
wl<-). => this is working now.