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

PlotRatios #77

Closed
thortb95 opened this issue Feb 17, 2022 · 5 comments
Closed

PlotRatios #77

thortb95 opened this issue Feb 17, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@thortb95
Copy link

Hi!
I´m trying running plotRatios and this work fine when I just run:
plotRatios(res.results)
image

But I get sections I don't want, like "Fjord-River_mouth" and "Fjord-Lake". I select sections:
plotRatios(res.results, sections = c("Fjord", "River_mouth", "River_mouth-Lake", "Lake"), type = "percentages")
This works, but when I change type to "absolutes" it doesn't work anymore. I also get color by group, something I don't want, I just want the figure without the mentioned sections. Is this possible? :)

image

@hugomflavio
Copy link
Owner

Hi!

Thanks for reaching out! It seems to me there are two separate issues here. I discuss them below.

# Let's make a minimal working example

library('actel')
example.residency.results <- c(example.results, additional.residency.results)
example.residency.results$rsp.info$analysis.type <- "residency"

# Problem 1: 'Undefined columns selected' error

plotRatios(example.residency.results) # note that type = 'absolutes' is the default

plotRatios(example.residency.results, sections = c('River', 'River-Fjord')) # works

plotRatios(example.residency.results, sections = c('River', 'River-Fjord'), type = 'percentages') # works

plotRatios(example.residency.results, sections = c('River', 'Fjord-Sea')) # does not work! <----- !!!!
# Error in `[.data.frame`(x, , c(1, match(sections, colnames(x)))) : 
#   undefined columns selected

plotRatios(example.residency.results, sections = c('River', 'Fjord-Sea'), type = 'percentages') # works




# Problem 2: Labelling a partial plot by section rather than by group

# Currently not possible. It would require a new argument, e.g.: 'colour.by', with values 'default', 'section', 'group'.

Regarding problem 1, congratulations, you found a bug! 😅 I will look into it and upload a fix as soon as I can. Regarding problem 2, as stated, the mechanism you are looking for does not exist yet, but I can make it happen. I will likely need some days to look into this, but once I have it working locally I will let you know!

@hugomflavio hugomflavio added the bug Something isn't working label Feb 17, 2022
@hugomflavio hugomflavio self-assigned this Feb 17, 2022
@thortb95
Copy link
Author

Thank u so much for your answers! woho my first bug. I´m waiting :D

@hugomflavio
Copy link
Owner

Update: The error occurs here. When a group does not show up at one of the required sections, the column doesn't exist, leading to the selection of 'undefined columns'. Changing the matching mechanism will fix this, just got to make sure the system doesn't do partial matches (temporarily making a placeholder column filled with 0's might be safer?). This brings up the need to consider what would happen if the group was not detected at any of the requested sections.

More updates to come.

hugomflavio added a commit that referenced this issue Mar 6, 2022
…ns simultaneously. Gave the user the power to decide how to colour the plot. Should finalize work required for #77
@hugomflavio
Copy link
Owner

@thortb95 The latest development version should both 1) fix the bug and 2) allow you to chose how to colour the plots using the new col.by argument. e.g. plotRatios(res.results, sections = c("Fjord", "River_mouth", "River_mouth-Lake", "Lake"), type = "percentages", col.by = "section")

Would you mind trying it out and letting me know how it goes? Follow the instructions below to install the dev version:

# If you don't have the package "remotes" installed, start with:
install.packages("remotes")

# This will install actel's development version:
remotes::install_github("hugomflavio/actel"
			build_opts = c("--no-resave-data", "--no-manual"),
			build_vignettes = TRUE)

library("actel")
# The displayed version should now be 1.2.1.9012
# If that is not the case, unload actel and load it again.

Thanks!

@hugomflavio
Copy link
Owner

Closing this one due to inactivity. Hopefully the error is fixed :)

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

No branches or pull requests

2 participants