drighelli / SpatialExperiment

55 stars 20 forks source link

Geometric transformations on entire object #99

Closed Nick-Eagles closed 5 months ago

Nick-Eagles commented 2 years ago

Hello,

I ran into a case where I found it useful to apply rotations, reflections, and translations to the entire SpatialExperiment object. So far, I just wrote code to adjust the spatialCoords following these transformations, since I noticed similar code already existed to adjust just the imgData slot (https://github.com/drighelli/SpatialExperiment/blob/a4d45fd86b64bcaf24d740e9266e7e9a64888367/R/imgData-methods.R#L235-L259). If you think geometric transformations that affect both the spatialCoords and imgData would be useful functionality, I'd be happy to do a pull request. I'm not yet familiar with writing code that adheres to required Bioconductor package syntax, but perhaps just providing what I have might still be a useful start.

Let me know if a pull request sounds appropriate-- otherwise, feel free to close this issue.

Thanks, -Nick

lcolladotor commented 2 years ago

Hi!

We'd love to submit a PR about this functionality since we think that it would be a good companion to the rotateImg() and mirrorImg() functions that already exist in SpatialExperiment as you also need to update the spatialCoords() for cases like the one @Nick-Eagles ran into.

Best, Leo

drighelli commented 2 years ago

Hi guys (@lcolladotor @Nick-Eagles),

thanks for standing up for this PR, I think that this could be a useful functionality for the class for cases like the one mentioned by @Nick-Eagles!

If you make such a PR we'll be happy to revise the code and merge it into the main branch once it all looks ok.

Thanks, Dario

lcolladotor commented 2 years ago

Hi Dario!

Thanks, this is great. This will be @Nick-Eagles's first PR, so it'll be a good training opportunity for him. We met earlier and explored a bit the internal code of SpatialExperiment. Overall, I think that the PR might go smoother if you can help us clarify a few things:

Or would it be easier if we had a 30 min Zoom call before Nick sends the PR?

Best, Leo

HelenaLC commented 2 years ago

Couple thoughts here-

Alternative: While writing this, a perhaps "cleaner" way (but I'm not sure), would be to have only rotate/mirrorData with an argument which = c("spatialImage", "spatialCoords", "both") or something - which can do everything. Of course, if the signature is a spatialImage, it defaults to that...

Just my thoughts, happy to have a quick zoom sometime... I definitely agree we should discuss before doing a PR to avoid repeated time spent on both sides 🙏

Nick-Eagles commented 2 years ago

Sorry for the delay-- could we meet (zoom) next week as some point? I've created a when2meet and tried to span times appropriate for everyone's time zones: https://www.when2meet.com/?14874569-cKL3E. Thanks!

Also, to quickly respond to your ideas (though I'm sure we can discuss more on zoom):

lcolladotor commented 2 years ago

Thanks Nick @Nick-Eagles! I just filled out the when2meet info. Helena @HelenaLC, if next week doesn't work we can expand the when2meet to other weeks. Or if you have a preferred time, we can try to switch meetings on our end to make it work.

Dario @drighelli and Lukas @lmweber, feel free to join us, though from talking to Lukas our understanding is that Helena would likely review this PR by Nick.

Best, Leo

lmweber commented 2 years ago

Happy to join the meeting too. I have filled out the when2meet.

HelenaLC commented 2 years ago

Filled out, free any time in the afternoons!

drighelli commented 2 years ago

I cannot next week, but feel free to meet without me :)

Thanks!

lcolladotor commented 2 years ago

Thanks for responding! I sent a calendar invitation and we'll keep you updated Dario.

Best, Leo

drighelli commented 2 years ago

Thanks!

lcolladotor commented 2 years ago

Hi everyone,

Here's a summary from our meeting today.

Screen Shot 2022-03-15 at 9 24 01 AM
lmweber commented 2 years ago

Here are my .Rproj settings:

Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
lcolladotor commented 2 years ago

Thanks Lukas!

Shouldn't NumSpacesForTab: 2 be NumSpacesForTab: 4 instead?

Here's the one I use in spatialLIBD for reference:

% more spatialLIBD.Rproj
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 4
Encoding: UTF-8

RnwWeave: knitr
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
LineEndingConversion: Posix

BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
lmweber commented 2 years ago

Ah yes, in this project we have been using 4 spaces for tabs.

I usually use 2, so here I have always been hitting tab twice. So yes, if you put 4 in your .Rproj it should be consistent automatically. Thanks!

lcolladotor commented 5 months ago

@Nick-Eagles was this issue resolved by #105? Or is there anything pending?

Thanks!

Nick-Eagles commented 5 months ago

This was indeed completed by #105, so I'll close this issue.