-
Notifications
You must be signed in to change notification settings - Fork 24
Add skinny PP index and vignette with jellyfish search #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jaydeep869
wants to merge
3
commits into
ggobi:master
Choose a base branch
from
Jaydeep869:scagnostic-pp-indices
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| --- | ||
| title: "Using the skinny index with jellyfish search" | ||
| output: rmarkdown::html_vignette | ||
| vignette: > | ||
| %\VignetteIndexEntry{Using the skinny index with jellyfish search} | ||
| %\VignetteEngine{knitr::rmarkdown} | ||
| %\VignetteEncoding{UTF-8} | ||
| --- | ||
|
|
||
| ```{r, include = FALSE} | ||
| knitr::opts_chunk$set( | ||
| collapse = TRUE, | ||
| comment = "#>", | ||
| cache = FALSE, | ||
| eval = TRUE, | ||
| rmarkdown.html_vignette.check_title = FALSE | ||
| ) | ||
| ``` | ||
|
|
||
| The `skinny` scagnostic basically tells you how thin a 2d point cloud looks. | ||
|
Jaydeep869 marked this conversation as resolved.
Outdated
|
||
| It comes from the `cassowaryr` package and is based on the ratio of the | ||
| alpha hull perimeter to its area — so higher values mean the points are stretched | ||
| out in a narrow, elongated way. | ||
|
|
||
| Here we'll try using `skinny()` as a projection pursuit index with `guided_tour`, | ||
| and use `search_jellyfish` as the optimiser since it tends to explore more broadly. | ||
|
|
||
| ```{r setup, message = FALSE} | ||
| library(tourr) | ||
| ``` | ||
|
|
||
| ## Setting up the data | ||
|
|
||
| We'll work with the `flea` data that comes with tourr. Just standardising the | ||
| numeric columns first so they're on a comparable scale. | ||
|
|
||
| ```{r} | ||
| f <- apply(flea[, 1:6], 2, function(x) (x - mean(x)) / sd(x)) | ||
| head(f) | ||
| ``` | ||
|
|
||
| ## Guided tour with skinny | ||
|
|
||
| We can pass `skinny()` into `guided_tour()` the same way you'd use `holes()` | ||
| or any other index. Adding `search_f = search_jellyfish` for the optimiser: | ||
|
|
||
| ```{r} | ||
| animate_xy(f, | ||
| tour_path = guided_tour(skinny(), | ||
| search_f = search_jellyfish), | ||
| col = flea$species) | ||
| ``` | ||
|
|
||
| If you run this in the console you'll see it animate — the tour tries to | ||
| find projections where the data looks as thin/elongated as possible. | ||
|
|
||
| ## Saving the tour path | ||
|
|
||
| It can be handy to save the tour and replay it afterwards, especially | ||
| if you want to look at it in a different display or just keep a record. | ||
|
|
||
| ```{r} | ||
| set.seed(2025) | ||
| path <- save_history(f, | ||
| guided_tour(skinny(), search_f = search_jellyfish), | ||
| max = 10) | ||
| animate_xy(f, planned_tour(path), col = flea$species) | ||
| ``` | ||
|
|
||
| ## Quick comparison with holes | ||
|
|
||
| Just to see how `skinny()` differs from something like `holes()` — the holes | ||
| index looks for projections with low density in the middle (good for finding | ||
| clusters), while skinny is looking for elongated structure. | ||
|
|
||
| ```{r} | ||
| set.seed(2025) | ||
| path_h <- save_history(f, guided_tour(holes()), max = 10) | ||
| animate_xy(f, planned_tour(path_h), col = flea$species) | ||
| ``` | ||
|
|
||
| You can see that `holes()` tends to tease apart the species groups, while | ||
| `skinny()` finds a different kind of structure — more stretched out views | ||
| of the data. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.