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

Circular angle calculations #123

Merged
merged 16 commits into from
May 7, 2024
Merged

Circular angle calculations #123

merged 16 commits into from
May 7, 2024

Conversation

dan-knight
Copy link
Collaborator

@dan-knight dan-knight commented Mar 28, 2024

Description

Fixes a bug in the refactored angle calculation code to return to the original "circular" behaviour of the v1 algorithm. Before this, child angles were calculated beginning at 0 degrees, meaning that levels moved directly "downward". This creates two problems for users:

  1. Trees will naturally be more congested as nodes "bunch up" in the middle.
  2. More angles will need to be overridden by the user to address this issue.

These changes mean that the user needs to specify far fewer angles to handle crowded trees. For many use cases, the automatic angle calculation will create a well-spaced tree. Beyond this, often only one or two angles in the first level of the tree need to be overridden to create ample visual space for lower levels with many nodes.

These changes have removed the existing override.angles() function, but I haven't yet deleted the code as it be useful in the future (perhaps for handling edge cases).

Examples

radial

tree.df <- data.frame(
    parent = c(NA, 1, 2, 2, 3, 3, 3, 3, 8, 8, 8, 10, 10, 11),
    angle = NA
    );
tree.df$angle[3] <- -90;
tree.df$angle[8] <- -40;

tree <- SRCGrob(tree.df);
grid.draw(tree);
Screenshot 2024-03-28 at 1 52 15 PM

fixed

tree.df <- data.frame(
    parent = c(NA, 1, 2, 2, 3, 3, 4, 4, 6, 7, 10, 10, 7),
    angle = NA
    );
tree.df$angle[3:4] <- c(-60, 60);

tree <- SRCGrob(tree.df);
grid.draw(tree);
Screenshot 2024-03-28 at 5 04 55 PM

Closes #122

Checklist

  • This PR does NOT contain Protected Health Information (PHI). A repo may need to be deleted if such data is uploaded.
    Disclosing PHI is a major problem1 - Even a small leak can be costly2.

  • This PR does NOT contain germline genetic data3, RNA-Seq, DNA methylation, microbiome or other molecular data4.

  • This PR does NOT contain other non-plain text files, such as: compressed files, images (e.g. .png, .jpeg), .pdf, .RData, .xlsx, .doc, .ppt, or other output files.

  To automatically exclude such files using a .gitignore file, see here for example.

  • I have read the code review guidelines and the code review best practice on GitHub check-list.

  • I have set up or verified the main branch protection rule following the github standards before opening this pull request.

  • The name of the branch is meaningful and well formatted following the standards, using [AD_username (or 5 letters of AD if AD is too long)]-[brief_description_of_branch].

  • I have added the major changes included in this pull request to the CHANGELOG.md under the next release version or unreleased, and updated the date.

Footnotes

  1. UCLA Health reaches $7.5m settlement over 2015 breach of 4.5m patient records

  2. The average healthcare data breach costs $2.2 million, despite the majority of breaches releasing fewer than 500 records.

  3. Genetic information is considered PHI.
    Forensic assays can identify patients with as few as 21 SNPs

  4. RNA-Seq, DNA methylation, microbiome, or other molecular data can be used to predict genotypes (PHI) and reveal a patient's identity.

@dan-knight dan-knight added the enhancement New feature or request label Mar 28, 2024
@dan-knight dan-knight added bug Something isn't working and removed enhancement New feature or request labels Apr 9, 2024
@whelena
Copy link
Collaborator

whelena commented Apr 9, 2024

I see that there are two fucntion to calculate angles (calculate.angles.radial and calculate.angles.fixed) Althought in the exmaples you showed the two SRCGrob calls look the same. How do users choose which function to use?

@dan-knight
Copy link
Collaborator Author

I see that there are two fucntion to calculate angles (calculate.angles.radial and calculate.angles.fixed) Althought in the exmaples you showed the two SRCGrob calls look the same. How do users choose which function to use?

They don't! Those are all handled internally depending on the complexity of the tree. The two methods are becoming very similar anyway, so I think it would be good to combine them before releasing v3. For now, I'm just accounting for both.

@dan-knight dan-knight merged commit 47fd30c into main May 7, 2024
6 checks passed
@dan-knight dan-knight deleted the danknight-circular-angles branch May 7, 2024 23:05
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

Successfully merging this pull request may close these issues.

Bug in auto-scaling?
2 participants