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

Remove metadata option #54

Open
g1o opened this issue Nov 30, 2021 · 3 comments
Open

Remove metadata option #54

g1o opened this issue Nov 30, 2021 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@g1o
Copy link

g1o commented Nov 30, 2021

If there is a duplicated metadata or an extra column in it there is no way to remove or modify the elements. This means that if you save an object with wrong metadata, you have to redo every step to generate another without the wrong metadata or extra column.

library(pagoo)
toy_rds <- system.file('extdata', 'campylobacter.RDS', package = 'pagoo')
a<-load_pangenomeRDS(toy_rds)
a$organisms$country<-NULL
# Error in (function ()  : 
#   unused argument (base::quote(new("DFrame", rownames = c("1", "2", "3", "4", "5", "6", "7"), nrows = 7, listData = list(1:7, 
#   c("FR15", "FR27", "AR1", "AR8", "AR12", "CA1", "TW6"), c("2008/170h", "2012/185h", "99/801", "04/875", "06/195", "001A-
#  0374", "1830"), c(2008, 2012, 1999, 2004, 2006, 2005, 2008), c("Human", "Human", "Bovine", "Bovine", "Bovine", "Human", 
#  "Human"), c("Feces", "Blood", "Prepuce", "Fetus", "VM", "Blood", "Blood"), c("ERS672247", "ERS672259", "ERS739235", 
#  "ERS739242", "ERS739246", "ERS686652", "ERS739261")), elementType = "ANY", elementMetadata = NULL, metadata = 
#  list())))
@iferres
Copy link
Owner

iferres commented Nov 30, 2021

Hi @g1o thanks for reporting this. It is actually fixed in the latest version, but not in CRAN. I should push it as soon as possible.
Please reinstall pagoo using:

devtools::install_github("iferres/pagoo")

Then you can use the $add_metadata() method to overwrite existing columns.
Let me know if this solves your problem.

@iferres
Copy link
Owner

iferres commented Nov 30, 2021

See #44

@iferres iferres changed the title Add a remove metadata option Remove metadata option Dec 1, 2021
@iferres iferres added bug Something isn't working enhancement New feature or request labels Dec 1, 2021
@iferres
Copy link
Owner

iferres commented Dec 1, 2021

Hi again @g1o , yesterday I was just leaving so I read the issue very quickly and I didn't consider the possibility of removing metadata. It's true a method to remove metadata should exist. Now it's only possible to modify columns:

library(pagoo)
toy_rds <- system.file('extdata', 'campylobacter.RDS', package = 'pagoo')
a <- load_pangenomeRDS(toy_rds)
df <- a$organisms
df$country <- "Brazil"
a$add_metadata(map = "org", as.data.frame(df))
a$organisms # Now all organisms are from Brazil (country column)
DataFrame with 7 rows and 8 columns
         org          id      strain      year     country        host      source   accession
    <factor> <character> <character> <integer> <character> <character> <character> <character>
1 16244_6_6         FR15   2008/170h      2008      Brazil       Human       Feces   ERS672247
2 16244_6_18        FR27   2012/185h      2012      Brazil       Human       Blood   ERS672259
3 17059_2_16         AR1      99/801      1999      Brazil      Bovine     Prepuce   ERS739235
4 17059_2_23         AR8      04/875      2004      Brazil      Bovine       Fetus   ERS739242
5 17059_2_27        AR12      06/195      2006      Brazil      Bovine          VM   ERS739246
6 17150_1_73         CA1   001A-0374      2005      Brazil       Human       Blood   ERS686652
7 17059_2_42         TW6        1830      2008      Brazil       Human       Blood   ERS739261

.. but a method to remove columns is needed.
I will leave this issue open and I will try to address it in the next release.
Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants