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

Enable create.boxplot to print different text label on each panel #5

Merged
merged 5 commits into from
Sep 3, 2021

Conversation

zhuchcn
Copy link
Member

@zhuchcn zhuchcn commented Aug 24, 2021

This is an work around to be able to set different text labels on each panel

Data: https://github.com/uclahs-cds/public-R-BoutrosLab-plotting-general/files/7003378/create.boxplot.data.txt

data <- read.table(file = 'create.boxplot.data.txt', header = TRUE);
dummy.data <- data.frame(
    expression_score = NA,
    sex = 'Male',
    gene = 'DDX3X'
    );
data <- rbind(data, dummy.data);
data <- data[order(data$gene, data$sex),]

# Assemble color vector
sex.colours <- replace(data$sex, which(data$sex == 'Male'),'dodgerblue');
sex.colours <- replace(sex.colours, which(data$sex == 'Female'), 'pink');
# Plot
ymin <- min(data$expression_score, na.rm = TRUE)
ymax <- max(data$expression_score, na.rm = TRUE)
ymax <- ymax + (ymax - ymin) * 0.15
p <- create.boxplot(
    formula = expression_score ~ sex | gene,
    data = data,
    add.stripplot = TRUE,
    points.col = sex.colours,
    text.labels = c('A', 'B'),
    text.x = 1.5,
    text.y = 0,
    add.text = TRUE,
    ylimits = c(ymin, ymax)
    );

image

Copy link
Contributor

@pboutros pboutros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was assigned to @dan-knight, please coordinate with him

Also, not in coding standard, please fix

@zhuchcn
Copy link
Member Author

zhuchcn commented Aug 24, 2021

@pboutros Just fixed the styling.

@dan-knight This does not fix #4 , but only enables setting different text labels on each panel. But I think the color can be handled in a similar manner.

@zhuchcn
Copy link
Member Author

zhuchcn commented Sep 3, 2021

@dan-knight I added some text in documentation.

The repo does not have branch protection currently. I think we should add it. But for best practice, can you approve it when you feel it is ready? @dan-knight

@dan-knight
Copy link
Contributor

@dan-knight I added some text in documentation.

The repo does not have branch protection currently. I think we should add it. But for best practice, can you approve it when you feel it is ready? @dan-knight

Definitely agree about the branch protection.

I tested the new labels and everything looks good to me. I'll merge this branch now, and then test the stripplot colour fix with this feature included.

@dan-knight dan-knight merged commit 3d37c21 into uclahs-cds:main Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants