Giter Site home page Giter Site logo

Feature request: karyo plot about ibdsim2 HOT 2 CLOSED

magnusdv avatar magnusdv commented on August 21, 2024
Feature request: karyo plot

from ibdsim2.

Comments (2)

magnusdv avatar magnusdv commented on August 21, 2024

This can already be done: The colorBy parameter is intended for exactly this purpose.

Example with full siblings:

library(ibdsim2)
#> Loading required package: pedtools

# Simulate sibs
x = nuclearPed(2)
s = ibdsim(x, sims=1, verbose = F)[[1]]

# Summarise IBD segments in a data.frame
a = as.data.frame(alleleSummary(s, 3:4))

# Logical vectors with mat/pat IBD status
pat = a$`3:p` == a$`4:p`
mat = a$`3:m` == a$`4:m`

# Add column with mat/pat IBD status
status = rep("", nrow(a)) 
status[!mat & !pat] = "No IBD"
status[mat & !pat] = "Maternal"
status[!mat & pat] = "Paternal"
status[mat & pat] = "Mat & pat"
a$status = status

# Convert to factor to enforce level ordering
a$status = factor(a$status, levels = c("No IBD", "Maternal", "Paternal", "Mat & pat"))
 
# Plot karyogram using "status" to control color
karyo_haploid(a, colorBy = "status", alpha = 0.8,  
              color = c("No IBD" = "white", 
                        Maternal = "brown1", 
                        Paternal = "cornflowerblue", 
                        "Mat & pat" = "darkolivegreen"))

from ibdsim2.

thoree avatar thoree commented on August 21, 2024

Great, nice figure, thanks!

from ibdsim2.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.