Skip to content

Commit

Permalink
Merge pull request #7 from ubeattie/feat/style_updates
Browse files Browse the repository at this point in the history
minor updates
  • Loading branch information
ZacharyRWeaver committed Nov 13, 2023
2 parents d9ca829 + 4f0bb6a commit 6a34b28
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions R/profrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
#' Column 1 is the unique identifier of an individual animal or sample
#' Column 2 is the time of the sample
#' Column 3-N are the columns of replicate data.
#' @param n_trials The number of rows an individual sample will have. For example,
#' @param n_timepoints The number of rows an individual sample will have. For example,
#' if the replicates were collected for individual 1 at times 15
#' and 30, for replicates A and B, the data frame would look like:
#'
#' | id | time | A | B |
#' |:--:|:----:|:-:|:-:|
#' | 1 | 15 | 1 | 2 |
#' | 1 | 30 | 3 | 4 |
#'
#' @param verbose A boolean parameter that defaults to FALSE. Determines whether messages are printed.
#'
#' @param sort A boolean parameter that defaults to TRUE. If TRUE, sorts the returned data frame by score. If FALSE, returns the data in the individual order it was provided in
#' @param verbose A boolean parameter that defaults to FALSE. Determines whether messages are printed.
#'
#' @returns Returns a data frame of the results, in the following form:
#'
Expand All @@ -40,16 +40,16 @@
#'
#' @examples
#' test_data <- profrep::example_two_point_data
#' results <- profrep::profrep(df=test_data, n_trials=2)
#' results <- profrep::profrep(df=test_data, n_timepoints=2)
#' print(results)
#'
#' @export
profrep <- function(df, n_trials, verbose=FALSE, sort=TRUE) {
profrep <- function(df, n_timepoints, sort=TRUE, verbose=FALSE) {
if (verbose) {message("Welcome to profrep!")}
n_cols <- ncol(df) # Number of columns in whole data frame
if (verbose) {message("Number of columns in input dataframe: ", n_cols)}

n_individuals = nrow(df) / n_trials # Number of individuals
n_individuals = nrow(df) / n_timepoints # Number of individuals
if (verbose) {message("Number of individuals: ", n_individuals)}

n_replicates <- n_cols - 2 # Number of replicates (because of how the df is defined)
Expand All @@ -66,7 +66,7 @@ profrep <- function(df, n_trials, verbose=FALSE, sort=TRUE) {

# Pass the list through the do_ordering function
ordered_df <- do_ordering(
n_trials=n_trials,
n_trials=n_timepoints,
id_list=ids,
df_list=individuals,
n_replicates=n_replicates,
Expand Down
10 changes: 5 additions & 5 deletions man/profrep.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-profrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test_that("profrep calculates correctly for given data examples", {
final_score = c(0.9581, 0.9356, 0.7876, 0.6719, 0.4809),
rank = c(1, 2, 3, 4, 5)
)
observed_two_point <- profrep::profrep(df=profrep::example_two_point_data, n_trials=2)
observed_two_point <- profrep::profrep(df=profrep::example_two_point_data, n_timepoints=2)
expect_equal(observed_two_point, expected_two_point)

expected_three_point <- data.frame(
Expand All @@ -20,6 +20,6 @@ test_that("profrep calculates correctly for given data examples", {
final_score = c(0.9548, 0.8901, 0.8651, 0.8601, 0.8512, 0.8388, 0.7132, 0.6268, 0.5004, 0.3390, 0.0505, 0.0099),
rank = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
)
observed_three_point <- profrep::profrep(df=profrep::sparrow_repeatability_three_point, n_trials=3)
observed_three_point <- profrep::profrep(df=profrep::sparrow_repeatability_three_point, n_timepoints=3)
expect_equal(observed_three_point, expected_three_point)
})
2 changes: 1 addition & 1 deletion vignettes/profrep.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Here, we see that there are no missing replicates for any individual at any time
Since we know how many trials we performed, we can easily perform the profile repeatability calculation with

```{r}
pr_score_df <- profrep::profrep(df=synthetic_data, n_trials=4)
pr_score_df <- profrep::profrep(df=synthetic_data, n_timepoints=4)
```

If we wanted logs to be displayed in the terminal, we would have changed the default verbosity factor from `FALSE` to `TRUE` with `verbose = True`.
Expand Down

0 comments on commit 6a34b28

Please sign in to comment.