From 9e2c6cc8dd4b6360d7156eccf7f7ecd67d036538 Mon Sep 17 00:00:00 2001
From: Flavio Lombardo <flavio.lombardo@unibas.ch>
Date: Sat, 11 Jan 2025 21:13:34 +0100
Subject: [PATCH] add more tests and inserted global variables, DOI fix

---
 .Rbuildignore                          |  4 +++
 .gitignore                             |  2 ++
 DESCRIPTION                            |  6 ++--
 R/change_data_format_to_longer.R       |  5 +--
 R/data_binding.R                       | 42 ++++++++++++--------------
 R/generate_qu_path_script.R            |  6 ++--
 R/get_QC_plots.R                       | 12 +++++---
 R/get_QC_plots_and_stats.R             |  8 +++--
 R/make_count_dataframe.R               | 20 +++++++++---
 R/make_run_config.R                    | 40 +++++++++++-------------
 R/parsers.R                            | 11 ++++---
 R/zzz.R                                | 10 ++++++
 README.md                              |  6 ++--
 man/change_data_format_to_longer.Rd    |  7 ++++-
 man/data_binding.Rd                    | 18 ++++++-----
 man/generate_qupath_script.Rd          |  4 ++-
 man/get_QC_plots.Rd                    |  6 ++++
 man/get_QC_plots_parsed_merged_data.Rd |  6 ++++
 man/make_count_dataframe.Rd            | 19 +++++++++---
 man/make_run_config.Rd                 |  5 +++
 man/process_file.Rd                    | 20 ++++++++++++
 man/string_parsing.Rd                  |  9 ++++--
 man/utils_internal.Rd                  | 13 ++++++++
 tests/testthat/test_cases.R            | 12 +++++---
 24 files changed, 199 insertions(+), 92 deletions(-)
 create mode 100644 R/zzz.R
 create mode 100644 man/process_file.Rd
 create mode 100644 man/utils_internal.Rd

diff --git a/.Rbuildignore b/.Rbuildignore
index 8ef5bf9..0e96ecb 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -5,3 +5,7 @@
 ^\.github$
 ^LICENSE\.md$
 ^cran-comments\.md$
+^config_drugsens\.txt$
+^script_for_qupath\.txt$
+^assets$
+^CRAN-SUBMISSION$
diff --git a/.gitignore b/.gitignore
index 13e0c95..2390fe4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,5 @@
 *.html
 figures/**
 temp/**
+.DS_Store
+*.txt
diff --git a/DESCRIPTION b/DESCRIPTION
index 9baf8b0..9c045b5 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,11 +1,11 @@
 Package: drugsens
-Title: Automated Analysis of QuPath Output Data and Metadata Extraction
+Title: Automated Analysis of 'QuPath' Output Data and Metadata Extraction
 Description: A comprehensive toolkit for analyzing microscopy data output from
-    QuPath software. Provides functionality for automated data processing,
+    'QuPath' software. Provides functionality for automated data processing,
     metadata extraction, and statistical analysis of imaging results.
     Designed to complement the STAR Protocol Protocol for quantifying drug 
     sensitivity in 3D patient-derived ovarian cancer models 
-    10.1016/j.xpro.2024.103274.
+    <doi:10.1016/j.xpro.2024.103274>.
 Version: 0.1.0
 BugReports: https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues
 SystemRequirements: QuPathâ„¢ 4.0.0 or higher
diff --git a/R/change_data_format_to_longer.R b/R/change_data_format_to_longer.R
index c10a11e..2de8294 100644
--- a/R/change_data_format_to_longer.R
+++ b/R/change_data_format_to_longer.R
@@ -1,6 +1,7 @@
 #' Reformat the counts data in longer format
 #' @description
 #' This function gets the count data data.frame, that has a wider format and it returns a longer-formatted data.frame
+#' @title Data format changer
 #' @importFrom tidyr pivot_longer
 #' @importFrom dplyr select
 #' @importFrom tidyselect any_of
@@ -11,6 +12,7 @@
 #' @param unique_name_row_identifier String that indicates the unique identifier for each image, defaults as "filter_image"
 #' @export
 #' @examples
+#' \dontrun{
 #' list_of_relabeling =list(  "PathCellObject" = "onlyDAPIPositve",
 #' "cCasp3" = "cCASP3",  "E-Cadherin: cCASP3" = "E-Cadherin and cCASP3",
 #' "EpCAM_E-Cadherin" = "E-Cadherin",
@@ -20,8 +22,7 @@
 #' counts_dataframe <- make_count_dataframe(bind_data)
 #' plotting_ready_dataframe <-
 #' change_data_format_to_longer(counts_dataframe)
-
-# adding the image number so to identify the distribution
+#' }
 
 # pivot_longer
 change_data_format_to_longer <- function(.data,
diff --git a/R/data_binding.R b/R/data_binding.R
index 2347259..0f805b6 100644
--- a/R/data_binding.R
+++ b/R/data_binding.R
@@ -1,19 +1,12 @@
 # Get a list of all the files that are in a user-specified folder and get a list of full paths
+#' Internal utility functions for file handling
+#' @name utils_internal
 #' @description
-#' This function lists the content of a selected folder either recursively or not
+#' This file contains internal utility functions for file handling and processing
 #' @keywords internal
-#' @returns list
-#' @name   "Name", "list_of_relabeling", "marker_positivity","marker_positivity_ratio", "x", "y"
 #' @importFrom utils read.csv
 #' @importFrom stats setNames
 #' @import roxygen2
-#'
-
-# important for the scripts
-globalVariables(c(
-  "Name", "list_of_relabeling", "marker_positivity",
-  "marker_positivity_ratio", "x", "y"
-))
 
 # list all the files
 list_all_files <- function(define_path, extension, recursive_search) {
@@ -33,13 +26,14 @@ list_all_files <- function(define_path, extension, recursive_search) {
   )
 }
 
-# Helper function to read and process a single file
-#' @description
-#' This function returns a processed single file
+# Process a Single File
+#' @title Process a Single File
+#' @name process_file
+#' @description This function returns a processed single file
 #' @param file_path Path to the file
 #' @param extension String File extension to filter
 #' @keywords internal
-#' @returns dataframe
+#' @return dataframe
 process_file <- function(file_path,
                          # relabeling_map,
                          extension) {
@@ -85,27 +79,31 @@ process_file <- function(file_path,
 }
 
 #' Merge all the dataframes coming out from the QuPath
+#' @name data_binding
 #' @description
-#' This function try to guess the string patterns that are in the dataset and then fill the dataframe
-#' with that information. Finally the data is combined and combined them into one file
+#' This function identifies string patterns in the dataset, fills the dataframe
+#' with that information, and combines all data into a single file
 #' @import knitr
 #' @importFrom stringr str_extract
-#' @return A `dataframe`/`tibble`.
 #' @param path_to_the_projects_folder String/Path The path where the files coming out of QuPath are located
 #' @param files_extension_to_look_for String The extension of the file outputted from QuPath, (default is "csv")
 #' @param recursive_search Boolean, it defined the behavior of the file search, if recursive or not, (default is FALSE)
-#' @returns Returns a concatenated dataframe from all the files within the indicated one
+#' @param forcePath String defining an alternative path to the confic file
+#' @return A concatenated dataframe from all the files within the indicated path
 #' @export
 #' @examples
+#' \dontrun{
 #' bind_data <- data_binding(path_to_the_projects_folder = system.file("extdata/to_merge/",
-#' package = "drugsens"))
-#' #This will return the dataframe of all the data in the folder
+#'                          package = "drugsens"))
+#'}
+
 # Main function to bind data from multiple files
 data_binding <- function(path_to_the_projects_folder,
                          files_extension_to_look_for = "csv",
-                         recursive_search = FALSE) {
+                         recursive_search = FALSE,
+                         forcePath = NULL) {
   # run configuration file
-  make_run_config()
+  make_run_config(forcePath = forcePath)
 
   # Validate input parameters
   if (!dir.exists(path_to_the_projects_folder)) {
diff --git a/R/generate_qu_path_script.R b/R/generate_qu_path_script.R
index 050661c..f006a2c 100644
--- a/R/generate_qu_path_script.R
+++ b/R/generate_qu_path_script.R
@@ -2,12 +2,12 @@
 #' @description
 #' Generate a useful script to consistently save the output data from QuPath in .csv format following the naming conventions
 #' followed during the package development.
-#'
 #' @return `script_for_qupath.txt` in local working directory.
-#'
 #' @export
 #' @examples
-#' generate_qupath_script()
+#' \dontrun{
+#'   generate_qupath_script()
+#' }
 generate_qupath_script <- function() {
   write(
     x = paste0('
diff --git a/R/get_QC_plots.R b/R/get_QC_plots.R
index 6f24033..8a5336f 100644
--- a/R/get_QC_plots.R
+++ b/R/get_QC_plots.R
@@ -8,13 +8,15 @@
 #' @param folder_name A string indicating the name of the folder where to save the plots in case that save_plots = TRUE
 #' @param isolate_a_specific_patient A string indicating the patient name to isolate for single plot case (default is NULL)
 #' @param x_plot_var A string indicating the treatment's full name for the QC plots (default is "Treatment_complete")
-#'
 #' @import ggplot2
 #' @import ggpubr
 #' @importFrom dplyr filter
 #' @return A `dataframe`/`tibble`.
-#' @example
-#' \dontrun{get_QC_plots(longer_format_dataframe, patient_column_name = "PID", save_plots = TRUE, folder_name = "figures")}
+#' @examples
+#' \dontrun{
+#'   get_QC_plots(longer_format_dataframe, patient_column_name = "PID",
+#'                save_plots = TRUE, folder_name = "figures")
+#' }
 #' @export
 get_QC_plots <- function(.data,
                          patient_column_name = "PID",
@@ -33,7 +35,9 @@ get_QC_plots <- function(.data,
 
     QC_plot <- .data |>
       dplyr::filter(.data[[patient_column_name]] == i) |>
-      ggplot(aes(x = !!as.name(x_plot_var), y = marker_positivity_ratio, col = marker_positivity)) +
+      ggplot(aes(x = .data[[x_plot_var]],
+                 y = .data$marker_positivity_ratio,
+                 col = .data$marker_positivity)) +
       geom_boxplot(
         position = position_dodge(width = 1.0),
       ) +
diff --git a/R/get_QC_plots_and_stats.R b/R/get_QC_plots_and_stats.R
index cf1ebd2..5571930 100644
--- a/R/get_QC_plots_and_stats.R
+++ b/R/get_QC_plots_and_stats.R
@@ -16,14 +16,16 @@
 #' @param p_height Integer, indicate the plot's height (default is 10 inches)
 #' @param p_width Integer, indicate the plot's width (default is 10 inches)
 #' @param drug_column_name String, indicate the column indicating the Drug/Treament (default is "Treatment")
-#'
 #' @import ggplot2
 #' @import ggpubr
 #' @importFrom readr write_excel_csv
 #' @importFrom dplyr filter
 #' @return A `list`/`NULL`.
-#' @example
-#' \dontrun {qc <- get_QC_plots_parsed_merged_data(bind_data, save_plots = TRUE, save_list_of_plots = TRUE)}
+#' @examples
+#' \dontrun{
+#'   qc <- get_QC_plots_parsed_merged_data(bind_data, save_plots = TRUE,
+#'                                        save_list_of_plots = TRUE)
+#' }
 #' @export
 
 get_QC_plots_parsed_merged_data <- function(.data,
diff --git a/R/make_count_dataframe.R b/R/make_count_dataframe.R
index d0c783a..2bc8358 100644
--- a/R/make_count_dataframe.R
+++ b/R/make_count_dataframe.R
@@ -8,12 +8,22 @@
 #' @param name_of_the_markers_column The name of the column of the .data where the marker names are expressed (ie E-Caderin, DAPI), "Defaults as Name"
 #' @export
 #' @examples
-#' bind_data <- data_binding(path_to_the_projects_folder = system.file("extdata/to_merge/", package = "drugsens"), files_extension_to_look_for = "csv")
+#' \dontrun{
+#' pkg_path <- system.file("extdata/to_merge/", package = "drugsens")
+#' bind_data <- data_binding(
+#'   path_to_the_projects_folder = pkg_path,
+#'   files_extension_to_look_for = "csv"
+#' )
 #' counts_dataframe <- make_count_dataframe(bind_data)
-#' plotting_ready_dataframe <- change_data_format_to_longer(counts_dataframe)
-#' @example
-#' \dontrun{make_count_dataframe(data, name_of_the_markers_column = "Name", unique_name_row_identifier = "filter_image")}
-#' @return text file
+#' plotting_ready_dataframe <- change_data_format_to_longer(
+#'   counts_dataframe
+#' )
+##'   make_count_dataframe(
+#'     data,
+#'     name_of_the_markers_column = "Name",
+#'     unique_name_row_identifier = "filter_image"
+#'   )
+#' }
 
 # adding the image number so to identify the distribution
 make_count_dataframe <- function(.data, unique_name_row_identifier = "filter_image",
diff --git a/R/make_run_config.R b/R/make_run_config.R
index 232cdc4..ab009a7 100644
--- a/R/make_run_config.R
+++ b/R/make_run_config.R
@@ -1,3 +1,5 @@
+# In make_run_config.R:
+
 #' Generates and use a config txt file
 #' @description
 #' When this function run the first time, it will generated a config.txt file in the user working directory.
@@ -7,16 +9,18 @@
 #' @param forcePath String, Define a custom path for the config file
 #' @export
 #' @return A `dataframe`/`tibble`.
-#' @example
-#' \dontrun {make_run_config()}
+#' @examples
+#' \dontrun{
+#'   make_run_config()
+#' }
 make_run_config <- function(overwrite_config = FALSE, forcePath = NULL) {
+  currentPath <- if (is.null(forcePath)) getwd() else forcePath
+  config_file <- file.path(currentPath, "config_drugsens.txt")
 
-  if (is.null(forcePath)) currentPath <- getwd() else currentPath <- forcePath
-
-  if (file.exists("config_drugsens.txt")) {
+  if (file.exists(config_file)) {
     tryCatch(
       expr = {
-        source("config_drugsens.txt", local = FALSE)
+        source(config_file, local = FALSE)
       },
       error = function(error) {
         message("drugsens could not load the 'config.txt' file.
@@ -26,13 +30,9 @@ make_run_config <- function(overwrite_config = FALSE, forcePath = NULL) {
                 run_config to veryfy that the data was correctly read")
       }
     )
-  } else if (overwrite_config){
-    message("Overwriting config_drugsens.txt")
+  } else if (overwrite_config) {
     write(
-      x =
-        (
-        '
-        # List of markers to relabel
+      x = '# List of markers to relabel
         list_of_relabeling =
         list(
             "PathCellObject" = "onlyDAPIPositve",
@@ -40,17 +40,12 @@ make_run_config <- function(overwrite_config = FALSE, forcePath = NULL) {
             "E-Cadherin: cCASP3" = "E-Cadherin and cCASP3",
             "EpCAM_E-Cadherin" = "E-Cadherin",
             "EpCAM_E-Cadherin and cCASP3" = "E-Cadherin and cCASP3"
-          )'
-        ),
-      file = paste0(path.expand(currentPath), "/config_drugsens.txt")
+          )',
+      file = config_file
     )
-    message("config_drugsens.txt has been overwritten correctly.")
   } else {
     write(
-      x =
-        (
-          '
-        # List of markers to relabel
+      x = '# List of markers to relabel
         list_of_relabeling =
         list(
             "PathCellObject" = "onlyDAPIPositve",
@@ -58,9 +53,8 @@ make_run_config <- function(overwrite_config = FALSE, forcePath = NULL) {
             "E-Cadherin: cCASP3" = "E-Cadherin and cCASP3",
             "EpCAM_E-Cadherin" = "E-Cadherin",
             "EpCAM_E-Cadherin and cCASP3" = "E-Cadherin and cCASP3"
-          )'
-        ),
-      file = paste0(path.expand(currentPath), "/config_drugsens.txt")
+          )',
+      file = config_file
     )
   }
 }
diff --git a/R/parsers.R b/R/parsers.R
index ed40c09..bc0153f 100644
--- a/R/parsers.R
+++ b/R/parsers.R
@@ -9,10 +9,13 @@
 #' @return A `dataframe`/`tibble`.
 #' @param .data dataframe with parsed metadata
 #' @examples
-#'  input_data <- data.frame(Image = "B516_Ascites_2023-11-25_DOC2020-12-14_dmso_rep_Ecad_cCasp3_(series 01).tif")
-#'  test <- drugsens:::string_parsing(input_data)
-#' @example
-#' \dontrun {data.parsed <- string_parsing(.data)}
+#' input_data <- data.frame(
+#'   Image = "B516_Ascites_2023-11-25_DOC2020-12-14_dmso_rep_Ecad_cCasp3_(series 01).tif"
+#' )
+#' test <- drugsens:::string_parsing(input_data)
+#' \dontrun{
+#'   data.parsed <- string_parsing(.data)
+#' }
 
 # Main function to bind data from multiple files
 string_parsing <- function(.data) {
diff --git a/R/zzz.R b/R/zzz.R
new file mode 100644
index 0000000..6f2304e
--- /dev/null
+++ b/R/zzz.R
@@ -0,0 +1,10 @@
+.onLoad <- function(libname, pkgname) {
+  utils::globalVariables(c(
+    "list_of_relabeling",
+    "marker_positivity_ratio",
+    "marker_positivity",
+    "x",
+    "y",
+    "Name"
+  ))
+}
diff --git a/README.md b/README.md
index 7fd35d7..e2e67f4 100644
--- a/README.md
+++ b/README.md
@@ -208,7 +208,7 @@ In this code snippets we show an example of mock data `unique(bind_data$PID)` wi
 
 > ⚠️ **WARNING**: As long as you keep the formatting as the above examples. 
 The dates should also be in the format **yyy-mm-dd**. For the combinations of two drugs they should be written together with each of the different drug capilized (**C**arboplatin**P**aclitaxel) and the rest lowercased letters. 
-For example **CarboplatinPaclitaxel_100_uM_10_nM**. This indicates a drug combination of Carboplatin 100_uM and Paclitaxel 10_nM. Each drug amount and each unit should always be separated by `_`. The first 100_uM belongs to the Carboplatin and the 10_nM belongs to the Paclitaxel. Those constrains are due to the parsing of the strings into useful metadata. If some of the data is not present, you can use a `.` separated by `_`. If you need additional data parsing, please let us know by filing an issue on GitLab [GitLab Issue]("https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues").
+For example **CarboplatinPaclitaxel_100_uM_10_nM**. This indicates a drug combination of Carboplatin 100_uM and Paclitaxel 10_nM. Each drug amount and each unit should always be separated by `_`. The first 100_uM belongs to the Carboplatin and the 10_nM belongs to the Paclitaxel. Those constrains are due to the parsing of the strings into useful metadata. If some of the data is not present, you can use a `.` separated by `_`. If you need additional data parsing, please let us know by filing an issue on GitLab https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues.
 
 ### Counting the number of positiive cells for each marker in every image
 This function will take the previous step's generated dataframe and it will counts image by image (sum the markers of every stack) for every sample the number of marker occurrences. 
@@ -386,6 +386,6 @@ Renv will automatically activate and install the necessary packages as specified
 </details>
 
 ### Reporting Issues
-If you encounter any bugs or have suggestions for improvements, please file an issue using our [GitLab Issue]("https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues"). Be sure to include as much information as possible to help us understand and address the issue.
-
+If you encounter any bugs or have suggestions for improvements, please file an issue using our **GitLab Issue:** https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues. Be sure to include as much information as possible to help us understand and address the issue.
+**BugReports:** https://git.scicore.unibas.ch/ovca-research/drugsens/-/issues
 Please make sure to file the issue in the GitLab repo as this one in GitHub is a forward-only mirror repo.
diff --git a/man/change_data_format_to_longer.Rd b/man/change_data_format_to_longer.Rd
index 93849cb..93a2d83 100644
--- a/man/change_data_format_to_longer.Rd
+++ b/man/change_data_format_to_longer.Rd
@@ -2,7 +2,7 @@
 % Please edit documentation in R/change_data_format_to_longer.R
 \name{change_data_format_to_longer}
 \alias{change_data_format_to_longer}
-\title{Reformat the counts data in longer format}
+\title{Data format changer}
 \usage{
 change_data_format_to_longer(
   .data,
@@ -26,7 +26,11 @@ A \code{dataframe}/\code{tibble}.
 \description{
 This function gets the count data data.frame, that has a wider format and it returns a longer-formatted data.frame
 }
+\details{
+Reformat the counts data in longer format
+}
 \examples{
+\dontrun{
 list_of_relabeling =list(  "PathCellObject" = "onlyDAPIPositve",
 "cCasp3" = "cCASP3",  "E-Cadherin: cCASP3" = "E-Cadherin and cCASP3",
 "EpCAM_E-Cadherin" = "E-Cadherin",
@@ -37,3 +41,4 @@ counts_dataframe <- make_count_dataframe(bind_data)
 plotting_ready_dataframe <-
 change_data_format_to_longer(counts_dataframe)
 }
+}
diff --git a/man/data_binding.Rd b/man/data_binding.Rd
index 1f1ebcc..13fd632 100644
--- a/man/data_binding.Rd
+++ b/man/data_binding.Rd
@@ -7,7 +7,8 @@
 data_binding(
   path_to_the_projects_folder,
   files_extension_to_look_for = "csv",
-  recursive_search = FALSE
+  recursive_search = FALSE,
+  forcePath = NULL
 )
 }
 \arguments{
@@ -16,18 +17,19 @@ data_binding(
 \item{files_extension_to_look_for}{String The extension of the file outputted from QuPath, (default is "csv")}
 
 \item{recursive_search}{Boolean, it defined the behavior of the file search, if recursive or not, (default is FALSE)}
+
+\item{forcePath}{String defining an alternative path to the confic file}
 }
 \value{
-A \code{dataframe}/\code{tibble}.
-
-Returns a concatenated dataframe from all the files within the indicated one
+A concatenated dataframe from all the files within the indicated path
 }
 \description{
-This function try to guess the string patterns that are in the dataset and then fill the dataframe
-with that information. Finally the data is combined and combined them into one file
+This function identifies string patterns in the dataset, fills the dataframe
+with that information, and combines all data into a single file
 }
 \examples{
+\dontrun{
 bind_data <- data_binding(path_to_the_projects_folder = system.file("extdata/to_merge/",
-package = "drugsens"))
-#This will return the dataframe of all the data in the folder
+                         package = "drugsens"))
+}
 }
diff --git a/man/generate_qupath_script.Rd b/man/generate_qupath_script.Rd
index 4e32a38..89b1816 100644
--- a/man/generate_qupath_script.Rd
+++ b/man/generate_qupath_script.Rd
@@ -14,5 +14,7 @@ Generate a useful script to consistently save the output data from QuPath in .cs
 followed during the package development.
 }
 \examples{
-generate_qupath_script()
+\dontrun{
+  generate_qupath_script()
+}
 }
diff --git a/man/get_QC_plots.Rd b/man/get_QC_plots.Rd
index 27070aa..0b4825e 100644
--- a/man/get_QC_plots.Rd
+++ b/man/get_QC_plots.Rd
@@ -35,3 +35,9 @@ A \code{dataframe}/\code{tibble}.
 \description{
 Plot data to visualize immediate trends
 }
+\examples{
+\dontrun{
+  get_QC_plots(longer_format_dataframe, patient_column_name = "PID",
+               save_plots = TRUE, folder_name = "figures")
+}
+}
diff --git a/man/get_QC_plots_parsed_merged_data.Rd b/man/get_QC_plots_parsed_merged_data.Rd
index 72eac55..221cc7e 100644
--- a/man/get_QC_plots_parsed_merged_data.Rd
+++ b/man/get_QC_plots_parsed_merged_data.Rd
@@ -53,3 +53,9 @@ A \code{list}/\code{NULL}.
 \description{
 This plot can show trends within the dataset and run some basic statistics.
 }
+\examples{
+\dontrun{
+  qc <- get_QC_plots_parsed_merged_data(bind_data, save_plots = TRUE,
+                                       save_list_of_plots = TRUE)
+}
+}
diff --git a/man/make_count_dataframe.Rd b/man/make_count_dataframe.Rd
index b118319..256353e 100644
--- a/man/make_count_dataframe.Rd
+++ b/man/make_count_dataframe.Rd
@@ -19,14 +19,25 @@ make_count_dataframe(
 }
 \value{
 A \code{dataframe}/\code{tibble}.
-
-text file
 }
 \description{
 This function counts every single marker present in the "Name" column of the data.frame and return a dataframe of the counts per marker
 }
 \examples{
-bind_data <- data_binding(path_to_the_projects_folder = system.file("extdata/to_merge/", package = "drugsens"), files_extension_to_look_for = "csv")
+\dontrun{
+pkg_path <- system.file("extdata/to_merge/", package = "drugsens")
+bind_data <- data_binding(
+  path_to_the_projects_folder = pkg_path,
+  files_extension_to_look_for = "csv"
+)
 counts_dataframe <- make_count_dataframe(bind_data)
-plotting_ready_dataframe <- change_data_format_to_longer(counts_dataframe)
+plotting_ready_dataframe <- change_data_format_to_longer(
+  counts_dataframe
+)
+  make_count_dataframe(
+    data,
+    name_of_the_markers_column = "Name",
+    unique_name_row_identifier = "filter_image"
+  )
+}
 }
diff --git a/man/make_run_config.Rd b/man/make_run_config.Rd
index 40042ef..a56cf8e 100644
--- a/man/make_run_config.Rd
+++ b/man/make_run_config.Rd
@@ -19,3 +19,8 @@ When this function run the first time, it will generated a config.txt file in th
 It will import the data config file into the use environment. This data will be used to change the column names
 of the imported dataset and change the name of the markers that is often incorrectly exported.
 }
+\examples{
+\dontrun{
+  make_run_config()
+}
+}
diff --git a/man/process_file.Rd b/man/process_file.Rd
new file mode 100644
index 0000000..db4b16b
--- /dev/null
+++ b/man/process_file.Rd
@@ -0,0 +1,20 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data_binding.R
+\name{process_file}
+\alias{process_file}
+\title{Process a Single File}
+\usage{
+process_file(file_path, extension)
+}
+\arguments{
+\item{file_path}{Path to the file}
+
+\item{extension}{String File extension to filter}
+}
+\value{
+dataframe
+}
+\description{
+This function returns a processed single file
+}
+\keyword{internal}
diff --git a/man/string_parsing.Rd b/man/string_parsing.Rd
index c6d8fc1..e6b8843 100644
--- a/man/string_parsing.Rd
+++ b/man/string_parsing.Rd
@@ -17,6 +17,11 @@ This function will parse the data from the Image name and will return the metada
 The metadata will be then associated to the count file as well
 }
 \examples{
- input_data <- data.frame(Image = "B516_Ascites_2023-11-25_DOC2020-12-14_dmso_rep_Ecad_cCasp3_(series 01).tif")
- test <- drugsens:::string_parsing(input_data)
+input_data <- data.frame(
+  Image = "B516_Ascites_2023-11-25_DOC2020-12-14_dmso_rep_Ecad_cCasp3_(series 01).tif"
+)
+test <- drugsens:::string_parsing(input_data)
+\dontrun{
+  data.parsed <- string_parsing(.data)
+}
 }
diff --git a/man/utils_internal.Rd b/man/utils_internal.Rd
new file mode 100644
index 0000000..a0dfbbe
--- /dev/null
+++ b/man/utils_internal.Rd
@@ -0,0 +1,13 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/data_binding.R
+\name{utils_internal}
+\alias{utils_internal}
+\alias{list_all_files}
+\title{Internal utility functions for file handling}
+\usage{
+list_all_files(define_path, extension, recursive_search)
+}
+\description{
+This file contains internal utility functions for file handling and processing
+}
+\keyword{internal}
diff --git a/tests/testthat/test_cases.R b/tests/testthat/test_cases.R
index 06d85a8..bb105ab 100644
--- a/tests/testthat/test_cases.R
+++ b/tests/testthat/test_cases.R
@@ -39,10 +39,13 @@ test_that("list_all_files returns correct file paths", {
 
 })
 
-test_that("Check that the config.txt is made and that it can be read", {
-  expect_silent(make_run_config())
-  expect_silent(make_run_config())
-  expect_true(file.exists(path.expand(path = paste0(getwd(), "/config_drugsens.txt"))))
+test_that("Config creation and reading works", {
+  temp_dir <- tempdir()
+  on.exit(unlink(file.path(temp_dir, "config_drugsens.txt")))
+
+  make_run_config(forcePath = temp_dir)
+  make_run_config(forcePath = temp_dir)
+  expect_true(file.exists(file.path(temp_dir, "config_drugsens.txt")))
   expect_true(exists("list_of_relabeling"))
 })
 
@@ -62,6 +65,7 @@ test_that("Config file was there and removed correctly", {
   expect_silent( file.remove(path.expand(paste0(getwd(), "/config_drugsens.txt"))) )
 })
 
+
 test_that("The parsing is working", {
   input_data <- data.frame(Image = "PID1_Tissue1_2024-02-13_DOC2024.02.13_TreatmentRana_10_uM_15_nm_Replica_(series.10)")
   expected_output <- data.frame(
-- 
GitLab