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
Is there a way to apply the spatial transformations to the entire giotto object, including the images?
I am joining multiple gobjs via joinGiottoObjects shift method, each with several fovs. However each has global coordinates from it's own original slide.
I would like to align them each to xmin = 0, ymin = 0 before joining them. Something like this:
# Load slide objects squares ----------------------------------------my_slides<- unlist(strsplit(slides, ","))
gobjs<- lapply(my_slides, function(i){
print(sprintf("Loading %s giotto object...", i))
loadGiotto(file.path(data_path, paste(i, group, "giotto_obj", sep=".")))
})
# shift each slide to the bottom-left most global coords (0,0) prior to merginggobjs<- lapply(gobjs, function(i) {
coords<- ext(i)
spatShift(i, dx=-coords$xmin, dy=-coords$ymin)
})
# merge the slides gobj<- joinGiottoObjects(
gobjs,
gobject_names=my_slides,
join_method="shift",
x_shift=NULL,
y_shift=NULL,
x_padding=0,
y_padding=NULL,
verbose=TRUE
)
That presents two problems: (1) figuring out the absolute bounds of all parts and (2) applying to all parts.
It would appear that I would have to call it on all images, spat_locs, spatNetwork, feature_info, and all polygon types and find the absolute xmin and ymin?
For the second, spatShift does appear to apply to a gobj, and seems to shift everything but the images. So for that do I basically have to modify the ext for each image after the initial? I was trying unsuccessfully to apply that with set.ext, but the way it works is counterintuitive to say the least
library(Giotto)
library(GiottoData)
go<- loadGiottoMini(dataset='cosmx')
go<- spatShift(go, dx=0, dy=150000)
lapply(names(go@images), function(i) {
img<- getGiottoImage(go, image_type='image', name=i)
e<- ext(img)
e<-e+ c(-0, 0, -150000, 150000) # I do not understand why it subtracts from ymin instead of addingterra::set.ext(img, e) # this fails unable to find an inherited method for function ‘set.ext’ for signature ‘"giottoImage"’
setGiottoImage(go,
image=img,
image_type='image',
name=i
)
})
# now the same for largeImages
The text was updated successfully, but these errors were encountered:
These functionalities should have just been added in GiottoClass 0.3.0
ext() now works on Giotto objects. It has a couple of params intended for finding the SpatExtent of specific pieces of information, but defaults to all the information in the object.
rescale() and spatShift() should also work on all the info in the Giotto object by default.
giottoImage extent is now settable. We don't provide methods for set.ext(), and have instead been writing methods for the ext()<- replacement function. Currently, the SpatExtent of giottoImage, giottoLargeImage, giottoPoints, and giottoPolygon are directly settable this way.
For the behavior of the SpatExtent object, we import this functionality from terra.
Numeric additions to a SpatExtent will expand one of the bounds, which is why you needed to apply negative values in order perform a shift.
Is there a way to apply the spatial transformations to the entire giotto object, including the images?
I am joining multiple gobjs via
joinGiottoObjects
shift method, each with several fovs. However each has global coordinates from it's own original slide.I would like to align them each to xmin = 0, ymin = 0 before joining them. Something like this:
That presents two problems: (1) figuring out the absolute bounds of all parts and (2) applying to all parts.
For the first,
ext
does not apply to a gobj:It would appear that I would have to call it on all images, spat_locs, spatNetwork, feature_info, and all polygon types and find the absolute xmin and ymin?
For the second,
spatShift
does appear to apply to a gobj, and seems to shift everything but the images. So for that do I basically have to modify theext
for each image after the initial? I was trying unsuccessfully to apply that withset.ext
, but the way it works is counterintuitive to say the leastThe text was updated successfully, but these errors were encountered: