Skip to content

Commit

Permalink
revert one change what should be on branch
Browse files Browse the repository at this point in the history
  • Loading branch information
werpuc committed Nov 13, 2024
1 parent e05476f commit 0a1dd0d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 73 deletions.
7 changes: 5 additions & 2 deletions R/fit_1_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ fit_1_exp <- function(fit_dat,

max_uptake <- fit_dat[["MaxUptake"]][1]

fit_params <- rbind(get_1_k_params(fit_k_params), get_1_n_params(fractional = fractional,
MaxUptake = max_uptake))
if(fractional){
fit_params <- rbind(get_1_k_params(fit_k_params), get_1_n_params())
} else {
fit_params <- rbind(get_1_k_params(fit_k_params), get_1_n_params(MaxUptake = max_uptake))
}

tryCatch({
if(fractional){
Expand Down
8 changes: 5 additions & 3 deletions R/fit_2_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ fit_2_exp <- function(fit_dat,
fit_2_types <- get_2_k_params(fit_k_params)
max_uptake <- fit_dat[["MaxUptake"]][1]

fit_2_n_params <- get_2_n_params(fractional = fractional,
MaxUptake = max_uptake)

if(fractional){
fit_2_n_params <- get_2_n_params()
} else {
fit_2_n_params <- get_2_n_params(MaxUptake = max_uptake)
}

fit_2_res <- lapply(fit_2_types, function(fit_2_params){

Expand Down
8 changes: 5 additions & 3 deletions R/fit_3_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ fit_3_exp <- function(fit_dat,

max_uptake <- fit_dat[["MaxUptake"]][1]

fit_params <- rbind(fit_k_params, get_3_n_params(fractional = fractional,
MaxUptake = max_uptake))

if(fractional){
fit_params <- rbind(fit_k_params, get_3_n_params())
} else {
fit_params <- rbind(fit_k_params, get_3_n_params(MaxUptake = max_uptake))
}

tryCatch({

Expand Down
87 changes: 22 additions & 65 deletions R/getters.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,15 @@ get_2_k_params <- function(fit_k_params){
}

#' @noRd
get_3_n_params <- function(fractional = TRUE,
MaxUptake = NA){
get_3_n_params <- function(MaxUptake = NA){

if(fractional){
if(is.na(MaxUptake)){

if(is.na(MaxUptake)){

data.frame(
start = c(n_1 = 0.33, n_2 = 0.33, n_3 = 0.33),
lower = c(n_1 = 0, n_2 = 0, n_3 = 0),
upper = c(n_1 = 1, n_2 = 1, n_3 = 1)
)

} else {

data.frame(
start = c(n_1 = 0.33, n_2 = 0.33, n_3 = 0.33),
lower = c(n_1 = 1/MaxUptake, n_2 = 1/MaxUptake, n_3 = 1/MaxUptake),
upper = c(n_1 = 1, n_2 = 1, n_3 = 1)
)
}
data.frame(
start = c(n_1 = 0.33, n_2 = 0.33, n_3 = 0.33),
lower = c(n_1 = 0, n_2 = 0, n_3 = 0),
upper = c(n_1 = 1, n_2 = 1, n_3 = 1)
)

} else {

Expand All @@ -94,76 +82,46 @@ get_3_n_params <- function(fractional = TRUE,

}


}

#' @noRd
get_2_n_params <- function(fractional = TRUE,
MaxUptake = NA){


if(fractional){

if(is.na(MaxUptake)){
data.frame(
start = c(n_1 = 0.5, n_2 = 0.5),
lower = c(n_1 = 0, n_2 = 0),
upper = c(n_1 = 1, n_2 = 1)
)
} else {

data.frame(
start = c(n_1 = 0.5, n_2 = 0.5),
lower = c(n_1 = 1/MaxUptake, n_2 = 1/MaxUptake),
upper = c(n_1 = 1, n_2 = 1)
)
}
get_2_n_params <- function(MaxUptake = NA){

if(is.na(MaxUptake)){
data.frame(
start = c(n_1 = 0.5, n_2 = 0.5),
lower = c(n_1 = 0, n_2 = 0),
upper = c(n_1 = 1, n_2 = 1)
)
} else {

data.frame(
start = c(n_1 = MaxUptake/2, n_2 = MaxUptake/2),
lower = c(n_1 = 0, n_2 = 0),
upper = c(n_1 = MaxUptake, n_2 = MaxUptake)
)
}



}

#' @noRd
get_1_n_params <- function(fractional = TRUE,
MaxUptake = NA){

if(fractional){

if(is.na(MaxUptake)){
data.frame(
start = c(n_1 = 1),
lower = c(n_1 = 0),
upper = c(n_1 = 1)
)
} else {
data.frame(
start = c(n_1 = 1),
lower = c(n_1 = 1/MaxUptake),
upper = c(n_1 = 1)
)
}
get_1_n_params <- function(MaxUptake = NA){

if(is.na(MaxUptake)){
data.frame(
start = c(n_1 = 1),
lower = c(n_1 = 0),
upper = c(n_1 = 1)
)
} else {

data.frame(
start = c(n_1 = MaxUptake*0.7),
lower = c(n_1 = 0),
upper = c(n_1 = MaxUptake)
)

}




}

#' @noRd
Expand Down Expand Up @@ -202,4 +160,3 @@ get_residue_positions <- function(fit_values){
})) %>% unique(.) %>% arrange(position)

}

0 comments on commit 0a1dd0d

Please sign in to comment.