Git Product home page Git Product logo

plotgenstruct's Introduction

plotGenStruct

Travis build status

The goal of plotGenStruct is to assist with plotting clustered genetic STRUCTURE datasets using the ggplot2 package. Data is automatically sorted into clusters and several palettes can be easily chosen.

Installation

At present the package can only be installed from github with:

# install.packages("devtools")
devtools::install_github("aj2duncan/plotGenStruct")

Plotting Data

Existing STRUCTURE data can be plotted using the function struc_plot(). If you don’t have any data to hand then some random data can be generated using the create_sruc_data() function

This is a basic example which shows you how to solve a common problem:

library(plotGenStruct)
create_struc_data()
# A tibble: 5,000 x 3
   Individual Cluster      q
   <chr>        <int>  <dbl>
 1 Ex101            1 0.063 
 2 Ex101            2 0.014 
 3 Ex101            3 0.0048
 4 Ex101            4 0.016 
 5 Ex101            5 0.183 
 6 Ex101            6 0.022 
 7 Ex101            7 0.007 
 8 Ex101            8 0.006 
 9 Ex101            9 0.008 
10 Ex101           10 0.676 
# ... with 4,990 more rows

To see what the reordered data looks like we can use struc_reorder().

struc_reorder(create_struc_data())
# A tibble: 5,000 x 4
   Individual Cluster     q main_cluster
   <chr>        <int> <dbl>        <int>
 1 Ex154            1 0.999            1
 2 Ex219            1 0.997            1
 3 Ex403            1 0.997            1
 4 Ex537            1 0.987            1
 5 Ex581            1 0.987            1
 6 Ex394            1 0.986            1
 7 Ex316            1 0.980            1
 8 Ex234            1 0.957            1
 9 Ex184            1 0.955            1
10 Ex152            1 0.953            1
# ... with 4,990 more rows

Finally we can plot the data.

struc_plot(create_struc_data())

Different Palettes

You can also specify different palettes which is just a short cut to several of the scale_fill_*() functions from ggplot2.

struc_plot(create_struc_data(), fill_pal = "viridis")

This includes a custom palette. Here we also specify only two clusters.

# custom palette
struc_plot(create_struc_data(num_clusters = 2), 
           fill_pal = "custom", values = c("blue", "red"))

plotgenstruct's People

Contributors

aj2duncan avatar

Watchers

James Cloos avatar  avatar

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.