Skip to content
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

Map stress in viewer is different from map stress given by function #136

Open
bamueh opened this issue Jul 7, 2022 · 3 comments
Open

Map stress in viewer is different from map stress given by function #136

bamueh opened this issue Jul 7, 2022 · 3 comments

Comments

@bamueh
Copy link

bamueh commented Jul 7, 2022

I have a map here where if I view it using >RacViewer(omiBeta) the stress is displayed as 2452.5, but when I output the stress using mapStress(omiBeta), it's 2175.375. Is this a bug or some feature?

Screenshot 2022-07-07 at 10 38 48

@bamueh
Copy link
Author

bamueh commented Jul 7, 2022

I can send the save file, but it's quite big, so maybe email's better than attaching it here.

@bamueh
Copy link
Author

bamueh commented Jul 7, 2022

I had a bit more of a look around:

## Look into merging optimising weirdness
m <- read.acmap('hacked_monte_map_w_2xBetaVax_nothing_else.ace')
omi_map <- read.acmap('omi_map.ace')

# merge and reoptimise. The m map contains sera with coordinates set to NA
omiBetaReoptM <- mergeMaps(m, omi_map, method = 'reoptimized-merge', 
                           number_of_dimensions = 2, number_of_optimizations = 1500, minimum_column_basis = "none")
omiBetaReoptM <- realignMap(omiBetaReoptM, m)
ptDrawingOrder(omiBetaReoptM) <- rev(ptDrawingOrder(omiBetaReoptM))
# --> mapStress(omiBetaReoptM) = 2175.375, Stress in Viewer = 2452.5, Stress after relaxing in Viewer = 2090.72

# Merge and optimise separately
omiBetaMergedNds <- mergeMaps(m, omi_map)
omiBetaMergedNds  <- optimizeMap(omiBetaMergedNds, number_of_dimensions = 2, number_of_optimizations = 1500, 
                                 minimum_column_basis = "none")
# --> this doesn't optimise at all, and gives this error 'Error: Map contains disconnected points (points that are not connected through any path of detectable titers so cannot be coordinated relative to each other). To optimize anyway, rerun with 'options = list(ignore_disconnected = TRUE)'.'

omiBetaMergedNds <- mergeMaps(m, omi_map)
omiBetaMergedNds  <- optimizeMap(omiBetaMergedNds, number_of_dimensions = 2, number_of_optimizations = 1500, 
                                 minimum_column_basis = "none", options = list(ignore_disconnected = TRUE))
# --> mapStress(omiBetaMergedNds) = 2084.419, Stress in Viewer = 2089.7, Stress after relaxing in Viewer = 2089.7

# Merge, remove sera/ag with NA coordinates, optimise 
omiBetaMerged <- mergeMaps(m, omi_map)
omiBetaMerged <- removeSera(omiBetaMerged, c('B1617-135', 'B1617-136', 'CC1053-06', '204624651', '204624723', '204624809',
                                             '204624833', '204624870', '204922561', '204924137', '204924168', '204977154',
                                             '204626924', '204795878', '204796660', '204796723', '204922625', '204923993',
                                             '204924530', '204924559', '204924654', '204924745', '204976968', 'CSpecVir37722'))
omiBetaMerged  <- optimizeMap(omiBetaMerged, number_of_dimensions = 2, number_of_optimizations = 1500, minimum_column_basis = "none")
# --> mapStress(omiBetaMerged) = 2084.217, Stress in Viewer = 2084.217, Stress after relaxing in Viewer = 2084.217

# Remove sera/ag with NA coords, reoptimized-merge
mm <- removeSera(m, c('B1617-135', 'B1617-136', 'CC1053-06', '204624651', '204624723', '204624809',
                      '204624833', '204624870', '204922561', '204924137', '204924168', '204977154',
                      '204626924', '204795878', '204796660', '204796723', '204922625', '204923993',
                      '204924530', '204924559', '204924654', '204924745', '204976968'))
omi_map_m <- removeSera(omi_map, c('CSpecVir37722'))
omiBetaReoptM <- mergeMaps(mm, omi_map_m, method = 'reoptimized-merge', 
                           number_of_dimensions = 2, number_of_optimizations = 1500, minimum_column_basis = "none")
# --> mapStress(omiBetaReoptM) = 2164.639, Stress in Viewer = 2440.47, Stress after relaxing in Viewer = 2084.26

This seems to suggest that the maps coming out of mergeMaps when run with method = 'reoptimized-merge' aren't fully relaxed.
But I still don't understand why the stress that's displayed in the viewer would be different than the stress displayed by mapStress().

@drserajames
Copy link
Member

I agree this is really strange behaviour.

I think the source might be the treatment of poorly connected points, ie reoptimized-merge does not remove these points which leads to higher stress. I don't know why stress is calculated differently in the viewer for the omiBetaMergedNds map.

If you send me the files, I can try to make a minimal reproducible example for Sam to work on when he's available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants