Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when input data is a dataframe or tibble #4

Open
arisp99 opened this issue Sep 15, 2021 · 0 comments
Open

Error when input data is a dataframe or tibble #4

arisp99 opened this issue Sep 15, 2021 · 0 comments
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@arisp99
Copy link
Member

arisp99 commented Sep 15, 2021

Bug Description

compute_coi and optimize_coi fail to run when the data is either a data frame or a tibble. They require data to be a matrix. This error is caused when our data is processed to be fed into the algorithims.

Data Frame

library(coiaf)

data_df <- data.frame(
  check.names = FALSE,
  row.names = c("FP0008-C","FP0009-C","FP0015-C","FP0016-C","FP0017-C"),
  `Pf3D7_01_v3-93378` = c(0, 0, 0, 0, 0),
  `Pf3D7_01_v3-93901` = c(0.882353, 1, 1, NA, 1),
  `Pf3D7_01_v3-94422` = c(0, 0, 0.22973, 0, 0),
  `Pf3D7_01_v3-94442` = c(0, 0, 0.30137, NA, 0),
  `Pf3D7_01_v3-94445` = c(0, 0, 0.3375, NA, 0)
)
str(data_df)
#> 'data.frame':    5 obs. of  5 variables:
#>  $ Pf3D7_01_v3-93378: num  0 0 0 0 0
#>  $ Pf3D7_01_v3-93901: num  0.882 1 1 NA 1
#>  $ Pf3D7_01_v3-94422: num  0 0 0.23 0 0
#>  $ Pf3D7_01_v3-94442: num  0 0 0.301 NA 0
#>  $ Pf3D7_01_v3-94445: num  0 0 0.338 NA 0

wsaf_df  <- data_df[1, ]
plaf_df <- colMeans(data_df, na.rm = T)
input_df <- tibble::tibble(wsaf = wsaf_df, plaf = plaf_df) %>% tidyr::drop_na()
compute_coi(input_df, "real", coi_method = "1")
#> Error: wsaf must be a non-recursive vector

Tibble

data_tb <- tibble::tibble(data_df)
str(data_tb)
#> tibble [5 × 5] (S3: tbl_df/tbl/data.frame)
#>  $ Pf3D7_01_v3-93378: num [1:5] 0 0 0 0 0
#>  $ Pf3D7_01_v3-93901: num [1:5] 0.882 1 1 NA 1
#>  $ Pf3D7_01_v3-94422: num [1:5] 0 0 0.23 0 0
#>  $ Pf3D7_01_v3-94442: num [1:5] 0 0 0.301 NA 0
#>  $ Pf3D7_01_v3-94445: num [1:5] 0 0 0.338 NA 0

wsaf_tb  <- data_tb[1, ]
plaf_tb <- colMeans(data_tb, na.rm = T)
input_tb <- tibble::tibble(wsaf = wsaf_tb, plaf = plaf_tb) %>% tidyr::drop_na()
optimize_coi(input_tb, "real", coi_method = "1")
#> Error: wsaf must be a non-recursive vector

Created on 2021-09-15 by the reprex package (v2.0.1)

@arisp99 arisp99 added the bug label Sep 15, 2021
@arisp99 arisp99 added this to the 1.0.1 milestone Sep 15, 2021
@arisp99 arisp99 added bug unexpected problem or unintended behavior and removed bug labels Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant