Skip to content

Commit

Permalink
update REACTIV data
Browse files Browse the repository at this point in the history
  • Loading branch information
WillmsIM committed Dec 17, 2024
1 parent 75ea61b commit 583e856
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 58 deletions.
2 changes: 1 addition & 1 deletion man/RADAR_valid_data_table_spiked_unspiked.Rd

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

2 changes: 1 addition & 1 deletion man/REACTIV_valid_data_table_spiked_unspiked.Rd

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

61 changes: 14 additions & 47 deletions vignettes/Power_analysis_REACTIV.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ editor_options:
rm(list = ls())
#devtools::install_git("https://gitlab.roqs.basf.net/WillmsIM/xetaana.git")
#install.packages("easystats")
lapply(c("readxl","tidyverse","xetaana","ARTool","broom","car","dplyr","emmeans","ggplot2","lme4","magrittr","MASS","multcomp","psych","tidyr", "kableExtra","knitr","purrr","gt","easystats","rlang","drc","truncnorm", "DHARMa"), require, character.only=TRUE)
lapply(c("readxl","tidyverse","xeredar","ARTool","broom","car","dplyr","emmeans","ggplot2","lme4","magrittr","MASS","multcomp","psych","tidyr", "kableExtra","knitr","purrr","gt","easystats","rlang","drc","truncnorm", "DHARMa", "devtools"), require, character.only=TRUE)
```

Expand All @@ -42,58 +42,21 @@ data <- xeredar::REACTIV_valid_data_table_spiked_unspiked |>
```

```{r}
#| label: FunctionCheckAna
#| include: false
check <- function(df,resultList){
for(i in unique(df$Compound)){
print(paste0(i, "Spiked", sep=" "))
datSpiked <- df |> filter(Compound == i & stringr::str_detect(Treatment, "Testosté|FETAX Testo|\\+ Testosterone") )
datSpiked$Conc <- factor(datSpiked$Conc, ordered=TRUE, levels=sort(unique(datSpiked$Conc)))
print(paste0(i, "Unspiked", sep=" "))
datUnspiked <- df |> filter(Compound == i & !stringr::str_detect(Treatment, "Testosté|FETAX Testo| + Testosterone") )
datUnspiked$Conc <- factor(datUnspiked$Conc, ordered=TRUE, levels=sort(unique(datUnspiked$Conc)))
MixedAnova <- MixedAnova <- lme4::lmer(Fluor ~ Conc+ (1|Replicate)+(1|Replicate:Conc), data = datSpiked, REML=TRUE)
resultSpiked <- xetaana::ana(dataframe =datSpiked, mixedaov = MixedAnova)
resultSpiked[["MixedAnova"]] <- MixedAnova
MixedAnova <- MixedAnova <- lme4::lmer(Fluor ~ Conc+ (1|Replicate)+(1|Replicate:Conc), data = datUnspiked, REML=TRUE)
resultUnspiked <- xetaana::ana(dataframe =datUnspiked, mixedaov = MixedAnova)
resultUnspiked[["MixedAnova"]] <- MixedAnova
resultList[[i]][["Spiked"]] <- resultSpiked
resultList[[i]][["Unspiked"]] <- resultUnspiked
}
resultList
}
```

```{r}
#| label: FunctionGetVarianceInfo
#| include: false
GetVarianceInfo <- function(SpikedUnspiked, ListAnovas, resultList){
GetVarianceInfo <- function(ListAnovas, resultList){
for(i in names(ListAnovas)){
MeanControl <- insight::get_intercept(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]])
VarianceControl <- insight::get_varcov(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]])[1,1]
SDExperiment <- insight::get_sigma(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]])
MeanControl <- insight::get_intercept(ListAnovas[[i]])
VarianceControl <- insight::get_varcov(ListAnovas[[i]])[1,1]
SDExperiment <- insight::get_sigma(ListAnovas[[i]])
CVControl <- SDExperiment/MeanControl
VarianceRep <- insight::get_variance(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]])$var.intercept[2]
VarianceConcRep <- insight::get_variance(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]])$var.intercept[1]
ICC <- performance::icc(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]], tolerance = 0)
VarianceRep <- insight::get_variance(ListAnovas[[i]])$var.intercept[2]
VarianceConcRep <- insight::get_variance(ListAnovas[[i]])$var.intercept[1]
ICC <- performance::icc(ListAnovas[[i]], tolerance = 0)
print(ICC)
simultedResiduals <- DHARMa::simulateResiduals(ListAnovas[[i]][[SpikedUnspiked]][["MixedAnova"]], plot = F)
simultedResiduals <- DHARMa::simulateResiduals(ListAnovas[[i]], plot = F)
zero_inflated <- as.numeric(DHARMa::testZeroInflation(simultedResiduals)[["p.value"]])
if(!is.list(ICC)){
ICC <- data.frame(adj_ICC = 0)
Expand Down Expand Up @@ -121,8 +84,12 @@ resultList
```{r}
#| include: false
resultList <- list()
ANOVAs <- furrr::future_map(data, ~ lme4::lmer(Fluor ~ Conc + (1|Replicate) + (1|Replicate:Conc), data = .x, REML = TRUE))
ANOVAs <- furrr::future_map(data, ~ purrr::possibly(function(df) {
lme4::lmer(Fluor ~ Conc + (1|Replicate) + (1|Replicate:Conc), data = df, REML = TRUE)
}, otherwise = "error", quiet = FALSE)(.x))
Variance_info <- list()
Variance_Info <- GetVarianceInfo(ListAnovas = ANOVAs, Variance_info)
```

Expand Down
9 changes: 0 additions & 9 deletions vignettes/creating_REACTIV_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ names <- stringr::str_replace(names, "-resultats R|-resultats R","")
names <- stringr::str_replace(names, "2022-CHG-Marlo-","")
```



```{r}
#| include: false
DataUSA <- extractDat(list=USA, path = path, names = names, results = CombinedDatUSA)
Expand All @@ -130,7 +128,6 @@ CombinedDatUSA <- spiked_unspiked(DataUSA, CombinedDatUSA)
```


```{r}
#| label: UKdat1
#| include: false
Expand Down Expand Up @@ -182,7 +179,6 @@ DataJapan <- map_df(DataJapan, ~as.data.frame(.x) |> dplyr::mutate(.x, Country =
CombinedDatJapan <- spiked_unspiked(DataJapan, CombinedDatJapan)
```


```{r}
#| label: Germanydat1
#| include: false
Expand All @@ -207,7 +203,6 @@ DataGermany <- map_df(DataGermany, ~as.data.frame(.x) |> dplyr::mutate(.x, Count
CombinedDatGermany <- spiked_unspiked(DataGermany, CombinedDatGermany)
```


```{r}
#| label: Francedat1
#| include: false
Expand All @@ -231,7 +226,6 @@ DataFrance <- map_df(DataFrance, ~as.data.frame(.x) |> dplyr::mutate(.x, Country
CombinedDatFrance <- spiked_unspiked(DataFrance, CombinedDatFrance)
```


```{r}
#| label: Denmarkdat1
#| include: false
Expand All @@ -253,9 +247,6 @@ DataDenmark <- map_df(DataDenmark, ~as.data.frame(.x) |> dplyr::mutate(.x, Count
CombinedDatDenmark <- spiked_unspiked(DataDenmark, CombinedDatDenmark)
```




```{r}
REACTIV_valid_data_table_spiked_unspiked <- c(CombinedDatUSA, CombinedDatUK, CombinedDatJapan, CombinedDatGermany, CombinedDatFrance, CombinedDatDenmark)
Expand Down

0 comments on commit 583e856

Please sign in to comment.