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

Bug: Slope Selector Plots Incorrect #177

Open
wants to merge 33 commits into
base: main
Choose a base branch
from

Conversation

js3110
Copy link
Collaborator

@js3110 js3110 commented Jan 24, 2025

Issue

Closes #165

Description

The slope selector plots do not always match the NCA results, showing the wrong line of best fit or points included in lambda z. This is best noticed when comparing the output of one analyte vs multiple analytes for the same subject profile.
For some multiple analyte studies, the slope plots crash with error message: Warning in max(lambda_z_ix_rows$AVAL) : no non-missing arguments to max; returning -Inf Warning: Error in if: missing value where TRUE/FALSE needed 87: lambda_slope_plot [/aNCA/R/lambda_slope_plot.R#134]

Looks like lamda.z.ix is being calculated incorrectly.
In addition, if user uses the table and selects 1:8 as manual slope, the selection includes 2,3,4,5,6,7 but not 1 and 8. Would be better if it was inclusive of the range the user inputs.

Definition of Done

  • Slope plots should correspond exactly to the NCA results, and be the same no matter how many analytes / pcspec have been selected.
  • Exclusions and inclusions should work fine, for both manual table adding or adding via interactive plots
  • Inclusions should include the IX values the user inputs
  • Should work for multiple analytes without crashing
  • Include entire range of points used to calculate lambda z

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented

Notes to reviewer

As well as fixing the bug issues, I have also refactored the code to avoid hardcoding the variables and instead created slopes_groups() reactive which takes the column names from mydata()$conc$columns$groups

@js3110 js3110 linked an issue Jan 24, 2025 that may be closed by this pull request
3 tasks
@js3110 js3110 self-assigned this Jan 24, 2025
@Gero1999 Gero1999 self-requested a review January 28, 2025 13:36
@Gero1999
Copy link
Collaborator

I will provide comments to the code as you requested @js3110!

R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/lambda_slope_plot.R Outdated Show resolved Hide resolved
R/lambda_slope_plot.R Show resolved Hide resolved
inst/shiny/tabs/nca.R Show resolved Hide resolved
@js3110 js3110 marked this pull request as ready for review January 31, 2025 09:34
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/create_duplicates.R Outdated Show resolved Hide resolved
R/utils-slope_selector.R Outdated Show resolved Hide resolved
R/utils-slope_selector.R Outdated Show resolved Hide resolved
R/utils-slope_selector.R Outdated Show resolved Hide resolved
inst/shiny/modules/slope_selector.R Outdated Show resolved Hide resolved
inst/shiny/modules/slope_selector.R Outdated Show resolved Hide resolved
@js3110
Copy link
Collaborator Author

js3110 commented Jan 31, 2025

Hi @m-kolomanski I have pushed some changes based on your comments. Regarding some of the functions, I am not sure if I have put them in the right place or if they need further documentation added, so please let me know!

Copy link
Collaborator

@Gero1999 Gero1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs detected

  • Plots per page input failed when changing it. I tested with DummyRO_with_metab, using multiple analyte. The error says:
TRACE [2025-02-04 11:39:30] slope_selector: Updating displayed plots
Warning: Error in if: argument is of length zero
  • With all default settings run, doing a selection in the first plot of Point4 > Point7 did add a row to the slopes table but did not change the plot

UI suggestions

  • It is super good that is good the plots have a standard size. But I feel they are way to big, which makes difficult comparison. If we are keen on keeping this size I would suggest increasing then the axis size

R/lambda_slope_plot.R Outdated Show resolved Hide resolved
inst/shiny/functions/handle_plotly_click.R Outdated Show resolved Hide resolved

log_trace("{id}: plotly click detected")

identifiers <- jsonlite::fromJSON(click_data$customdata)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: do we really need this dependency? jsonlite::fromJSON / jsonlite::toJSON
Maybe is easier to just make identifiers a regular dataframe with dplyr or base?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind, I did this because I had an issue with "_" in the value names causing the identifiers to be split wrong, but I'm sure it could be manually coded. What do you think is best @m-kolomanski @Gotfrid ?

R/lambda_slope_plot.R Outdated Show resolved Hide resolved
@js3110
Copy link
Collaborator Author

js3110 commented Feb 4, 2025

Bugs detected

  • Plots per page input failed when changing it. I tested with DummyRO_with_metab, using multiple analyte. The error says:

As discussed, we have a new issue #192 to solve this, as its not related to this issue.

  • With all default settings run, doing a selection in the first plot of Point4 > Point7 did add a row to the slopes table but did not change the plot

This is covered in issue #121 so I will leave it for there

UI suggestions

  • It is super good that is good the plots have a standard size. But I feel they are way to big, which makes difficult comparison. If we are keen on keeping this size I would suggest increasing then the axis size

I agree, the problem is when I make them smaller, they are too small on the small screen. At the moment if you have more than 2 plots per page they just appear underneath in the same size, and you have to scroll down to view, which makes them too big on the big screen. It would be good if there was a way to set the container size and then even if you add more plots per page they stay within the container. Do you know how to do this @m-kolomanski ? My knowledge of css and styling is limited 😨

@js3110
Copy link
Collaborator Author

js3110 commented Feb 5, 2025

@Gero1999 @m-kolomanski @Gotfrid I have had a go at changing the styling for the plots. On a big screen, it works fairly nicely and as intended, however on the small screen for some reason it disregards everything that is coded in css and just does whatever it wants. I can't seem to solve that 😅 .
The other issue I have noticed is that the "previous_page"and "next_page" buttons are not disabled when they are supposed to be, which means the user can click when they shouldn't and cause a crash. I was also unable to solve this...
So I would appreciate some help ! Thanks

@js3110 js3110 added the help wanted Extra attention is needed label Feb 5, 2025
@Gero1999
Copy link
Collaborator

Gero1999 commented Feb 5, 2025

Bugs detected

  • Plots per page input failed when changing it. I tested with DummyRO_with_metab, using multiple analyte. The error says:

As discussed, we have a new issue #192 to solve this, as its not related to this issue.

As we talked I rebased the branch to solve the multiple analytes metabolites case, so we can use DummyRO_with_metab.csv for the testing

@js3110 js3110 requested a review from Gero1999 February 10, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: Needs review
Development

Successfully merging this pull request may close these issues.

Bug: Slope Selector Plots incorrect
3 participants