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

H-Score report fix #63

Open
wants to merge 11 commits into
base: 9000
Choose a base branch
from
Open

Conversation

christianrickert
Copy link

Aim of this PR is to address an issue with phenoptrReport when reporting H-Score values for cells missing mean pixel intensity measurements (#N/A). Measurement can be missing when the corresponding cellular compartment (cytoplasm, membrane) is missing as a result of cell segmentation. Cells mostly affected will be those located in densely packed clusters, where the cell expansion of the cytoplasm failed due to the presence of neighboring cells in close proximity.

  • The previous version assigns cells lacking a measurement to the 3+ category
  • The fixed version does not assign cells lacking a measurement to any category

It has to be noted that the results of the fixed version of phenoptrReports may deviate from inForm.

  • Inform seems to assign cells lacking a measurement to the 0+ category

As part of QC, compare the total number of cells reported in the Cell Counts tab with the corresponding total number of cells in the individual H-Score tabs. A significant reduction of available cells for the H-Score calculation indicates cell segmentation issues. As a workaround, a different, physiologically relevant, compartment may be selected for scoring.

phenoptrReports passes all tests without warnings.

HIMSR noticed an issue with the H-Score report in phenoptrReports being noticeably off.

Akoya offered a possible explanation: Cells without valid compartment measurements (missing cytoplasm with corresponding mean intensities given as `#N/A`) are erroneously put into the 3+ category.

This fix places all intensity measurements with numerical values (existing cell compartment) into their respective H-Score categories, while ignoring all non-numerical (`#N/A`) values. Notice that this means that cells without valid compartments are not reported in the H-score summary.
Error message was:
```> write_h_score_sheet(wb, h_score_1)
Warning: Error in str_replace_all: `string` must be a vector, not a symbol.
  2: shiny::runApp
  1: phenoptrReports:::addin_30_analysis_app
```
It turns out that the function `remove_marker_mean` is called with a symbol instead of a string.

The fix avoids side effects by casting the function argument `s` to string before use.
`sum(1:3, NA)` evaluates to `NA`, if the `na.rm` parameter is not set to remove `NA` values prior to calculating the sum.
```
Returning data frames from `filter()` expressions was deprecated in dplyr 1.0.8.
ℹ Please use `if_any()` or `if_all()` instead.
ℹ The deprecated feature was likely used in the phenoptrReports package.
  Please report the issue at
  <https://github.com/akoyabio/phenoptrReports/issues>.
```
```
── Warning (test_smoke.R:136:3): file generation works ─────────────────────────
`cross2()` was deprecated in purrr 1.0.0.
i Please use `tidyr::expand_grid()` instead.
i See <tidyverse/purrr#768>.
```
When comparing H-Score values from (previous) `phenoptrReports` and (current) `inForm`, it's important to understand that both scored missing measurements into extreme categories (`3+`/`0+`) skewing the reported values depending on the number of missing measurements.

The current version of `phenoptrReports` omits missing measurements completely and reports adjusted counts and percentages.
When a specific phenotype hasn't been identified for a particular slide, the H-Scores were erroneously reported as `FALSE` values.
This fix inserts missing counts as `NA` values.
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

Successfully merging this pull request may close these issues.

1 participant