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 fix for fredman posthoc #485

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

bug fix for fredman posthoc #485

wants to merge 1 commit into from

Conversation

boxizhang
Copy link
Contributor

Title: Debug of the Friedman posthoc tests

Problem: When the data is not sorted by tested variable and subject, there is a chance that the paired Wilcoxon test will not be performed properly

Solution: sort the data based on tested variable and subject.

Key Features:

  • Key feature 1
  • Key feature 2
  • ...

Checklist

  • Make sure you are requesting to pull a feature/bugfix branch (right side). This should not be main or develop.
  • Make sure you are make a pull request against either main or develop (left side). (Requesting to main should be reserved for bugfixes and new releases)
  • Add or update unit tests (if applicable)
  • Check your code with any unit tests (Run devtools::check() locally)
  • Add neccessary documentation (if applicable)

Type of changes

What type of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue) (link the issue on the right)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code style update (formatting, renaming)
  • Documentation Update
  • Other (explain)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, any questions you have, etc...

Consider linking any issues (#issue-number ) or adding @mentions to ensure specific people see it.

Copy link
Contributor

@kathy-nevola kathy-nevola left a comment

Choose a reason for hiding this comment

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

There were a few parts I wasnt sure about, see my questions. Happy to schedule a meeting if that would be easier.

@@ -311,6 +313,7 @@ olink_one_non_parametric_posthoc <- function(df,
olinkid_list = NULL,
variable,
test = "kruskal",
subject = "Subject",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this default to Null and expect that there is no subject data

@@ -259,6 +260,7 @@ olink_one_non_parametric <- function(df,
#' @param olinkid_list Character vector of OlinkID's on which to perform post hoc analysis. If not specified, all assays in df are used.
#' @param variable Single character value or character array.
#' @param test Single character value indicates running the post hoc test for friedman or kruskal.
#' @param subject Single character value indicates running the post hoc test for friedman or kruskal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the name of a column or just a string. If there are options we should specify them in the documentation

@@ -259,6 +260,7 @@ olink_one_non_parametric <- function(df,
#' @param olinkid_list Character vector of OlinkID's on which to perform post hoc analysis. If not specified, all assays in df are used.
#' @param variable Single character value or character array.
#' @param test Single character value indicates running the post hoc test for friedman or kruskal.
Copy link
Contributor

Choose a reason for hiding this comment

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

add strings for tests

dplyr::select(!!!rlang::syms(subject)) %>%
dplyr::pull() %>%
unique())){
message(paste("Subjects removed due to incomplete data"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add list of subject IDs?

Copy link
Contributor

Choose a reason for hiding this comment

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

Are subjects only removed from specific assays?

dplyr::mutate(Friedman_remove = "no") %>%
dplyr::select(-n)

if(length(subject_remove %>%
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the Friedman test not work with subjects that are missing timepoints?

' has only NA:s in atleast one level of ',
effect,
'. It will not be tested.'),
call. = F)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
call. = F)
call. = FALSE)

}
}

formula_string <- paste0(data_type, "~", paste(variable,collapse="*"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the formula include subject as well? Like in the LME? (Unsure how this model using the formula string)

unique() %>%
pull() %>%
length()

Copy link
Contributor

Choose a reason for hiding this comment

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

n_subject -> number of levels in a variable?

dplyr::filter(n == n_subject) %>%
dplyr::mutate(Friedman_remove = "no") %>%
dplyr::select(-n)

Copy link
Contributor

Choose a reason for hiding this comment

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

subject_remove -> subject-Assay combos that are not missing levels of the variable

@@ -41,6 +41,7 @@ kruskal_posthoc_results <- olink_one_non_parametric_posthoc(npx_data1,
friedman_posthoc_results <- olink_one_non_parametric_posthoc(npx_data1,
variable = "Time",
test = "friedman",
subject = "Subject",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a unit test to test for this case?

@kathy-nevola
Copy link
Contributor

Can we also address Issue #346 in this PR

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