Skip to content

Commit

Permalink
doc updata
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Apr 30, 2024
1 parent 0e6907e commit d0dd6fa
Show file tree
Hide file tree
Showing 66 changed files with 238 additions and 119 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export(aggregate_contrast)
export(aggregate_intensity_topN)
export(apply_to_response_matrix)
export(build_model)
export(build_models)
export(complete_cases)
export(compute_pooled)
export(contrasts_fisher_exact)
Expand Down
11 changes: 0 additions & 11 deletions R/A_dataset_docu.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,6 @@ NULL
# #@usage data_IonstarProtein_subsetNorm <- prolfqua_data("data_IonstarProtein_subsetNorm")


# data_factor_levelContrasts <- factor_levelContrasts
# usethis::use_data(data_factor_levelContrasts, compress = TRUE, overwrite = TRUE)
# file.remove("data/factor_levelContrasts.rda")

#' example data for check
#' @family data
#' @docType data
#' @keywords internal
'data_factor_levelContrasts'

# #@usage data_factor_levelContrasts <- prolfqua_data("data_factor_levelContrasts")


#' example data for check
Expand Down
64 changes: 38 additions & 26 deletions R/tidyMS_R6_Modelling.R
Original file line number Diff line number Diff line change
Expand Up @@ -556,16 +556,38 @@ linfct_from_model <- function(m, as_list = TRUE){
}
}

#' make interaction model for examples
#' build dataframe with models for testing
#' @family modelling
#' @export
#' @example path.R
make_model <- function(model = " ~ Treatment * Background"){
istar <- prolfqua::sim_lfq_data_protein_2Factor_config(Nprot = 1,with_missing = FALSE)
#' @keywords internal
#' @example
#' mod <- build_models(model = " ~ Treatment * Background", weight_missing = 1)
#' stopifnot(dim(mod$modelDF) == c(10,9))
#'
build_models <- function(model = c("factors", "interaction"), Nprot = 10, with_missing = TRUE, weight_missing = 1) {
model <- match.arg(model)
model <- if (model == "factors") {
"~ Treatment * Background"
} else {
"~ Treatment + Background"
}
istar <- prolfqua::sim_lfq_data_protein_2Factor_config(Nprot = Nprot, with_missing = with_missing, weight_missing = weight_missing)
istar <- prolfqua::LFQData$new(istar$data,istar$config)
modelFunction <- strategy_lm(paste0(istar$response(), model))
mod <- build_model(
istar,
modelFunction)
return(mod)
}

#' make interaction model for examples
#' @family modelling
#' @export
#' @keywords internal
#' @example path.R
#' m <- make_model()
make_model <- function(model = c("factors", "interaction")){
mod <- build_models(model = model, Nprot = 1, with_missing = FALSE)
return(mod$modelDF$linear_model[[1]])
}

Expand Down Expand Up @@ -933,9 +955,8 @@ my_contest <- function(model, linfct, ddf = c("Satterthwaite", "Kenward-Roger"))
#' @family modelling
#' @keywords internal
#' @examples
#' dd <- prolfqua_data('data_factor_levelContrasts')
#' tmp <- pivot_model_contrasts_2_Wide(dd, subject_Id = "Compound")
#' stopifnot(all(dim(tmp) == c(30,16)))
#'
#' # this function is used by the contrast classes to implement the to wide method
#'
pivot_model_contrasts_2_Wide <- function(modelWithInteractionsContrasts,
subject_Id = "protein_Id",
Expand Down Expand Up @@ -963,19 +984,17 @@ pivot_model_contrasts_2_Wide <- function(modelWithInteractionsContrasts,
#' @export
#' @keywords internal
#' @examples
#' data("data_modellingResult_A")
#' modelSummary_A <- data_modellingResult_A
#' m <- get_complete_model_fit(modelSummary_A$modelProtein)
#' #data("data_modellingResult_A")
#' #modelSummary_A <- data_modellingResult_A
#' modelSummary_A <- build_models()
#' m <- get_complete_model_fit(modelSummary_A$modelDF)
#'
#' factor_contrasts <- linfct_factors_contrasts( m$linear_model[[1]])
#' class(factor_contrasts)
#' class(factor_contrasts)
#' factor_levelContrasts <- contrasts_linfct( m,
#' factor_contrasts,
#' subject_Id = "Compound",
#' subject_Id = "protein_Id",
#' contrastfun = prolfqua::my_contrast_V2)
#'
#' #usethis::use_data(factor_levelContrasts, overwrite = TRUE)
#'
contrasts_linfct <- function(models,
linfct,
Expand Down Expand Up @@ -1008,8 +1027,6 @@ contrasts_linfct <- function(models,
#interaction_model_matrix <- models |>
# dplyr::mutate("contrast" := purrr::map(!!sym(modelcol) , contrastfun , linfct = linfct ))



mclass <- function(x){
class(x)[1]
}
Expand Down Expand Up @@ -1047,7 +1064,7 @@ moderated_p_limma <- function(mm, df = "df", estimate = "diff", robust = FALSE,
sv <- prolfqua::squeezeVarRob(mm$sigma^2, df = mm[[df]],robust = robust)

# pior degrees of freedom are Inf
if(all(is.infinite(sv$df.prior))) {
if (all(is.infinite(sv$df.prior))) {
sv$df.prior <- mean(mm[[df]]) * nrow(mm)/10
}

Expand Down Expand Up @@ -1076,22 +1093,17 @@ moderated_p_limma <- function(mm, df = "df", estimate = "diff", robust = FALSE,
#' @keywords internal
#' @examples
#'
#'
#' modelSummary_A <- prolfqua_data('data_modellingResult_A')
#' m <- get_complete_model_fit(modelSummary_A$modelProtein)
#' mod <- build_models()
#' m <- get_complete_model_fit(mod$modelDF)
#' factor_contrasts <- linfct_factors_contrasts(m$linear_model[[1]])
#' factor_levelContrasts <- contrasts_linfct(
#' modelSummary_A$modelProtein,
#' mod$modelDF,
#' factor_contrasts,
#' subject_Id = "Compound",
#' subject_Id = "protein_Id",
#' contrastfun = my_contrast_V2)
#'
#' mmm <- moderated_p_limma_long(factor_levelContrasts, group_by_col = "lhs")
#'
#' plot(mmm$p.value, mmm$moderated.p.value, log = "xy")
#' abline(0,1, col = 2)
#'
#' # updating lmer model
moderated_p_limma_long <- function(mm ,
group_by_col = "lhs",
estimate = "estimate",
Expand Down
Binary file removed data/data_factor_levelContrasts.rda
Binary file not shown.
5 changes: 1 addition & 4 deletions inst/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
/doc/*
/Hurdle_R/*
/githubtickets/*
/plotly_reports/*
issue71/*
2 changes: 2 additions & 0 deletions man/Contrasts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsMissing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsModerated.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsPlotter.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsProDA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsROPECA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/ContrastsTable.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/INTERNAL_FUNCTIONS_BY_FAMILY.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/LR_test.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/Model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/PACKAGE_DATA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/build_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d0dd6fa

Please sign in to comment.