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

Feature request: map multiple numerical and categorical data to plots #766

Closed
ljournot opened this issue Dec 9, 2015 · 5 comments · Fixed by #1423
Closed

Feature request: map multiple numerical and categorical data to plots #766

ljournot opened this issue Dec 9, 2015 · 5 comments · Fixed by #1423

Comments

@ljournot
Copy link

ljournot commented Dec 9, 2015

I am 1) a newbie to Julia (and to programming) 2) a biologist 3) French. It's tough but c'est la vie !
In biology we often want to map several kind of numerical (e.g. fold enrichment, gene counts, p-value) and categorical (e.g. gene ontology category) data in a single plot. Some colleagues of mine produced the attached plot using R and ggplot2. I failed to produce a similar plot using Gadfly. I could map the p-value to the point color (Scale.ContinuousColorScale(Scale.lab_gradient(colorant"white",colorant"orange",colorant"red"))), but could not change their shape and size to map GO category and gene count, respectively. I suspect a solution might be something like change the Theme for each point, but it sounds quite complicated and I still don't find out how to change the shape depending on categorical values. Any idea ?

Thanks a lot for your help.

laurent

fairy_lights_go

@tbreloff
Copy link
Contributor

tbreloff commented Dec 9, 2015

I might be able to help, but it would be much easier if you supplied your data. Can you copy it into into a github gist?

@tbreloff
Copy link
Contributor

tbreloff commented Dec 9, 2015

So I took a stab at this using Plots.jl (honestly, I don't plan on attempting this in pure Gadfly, I think it will be too annoying)

tmp

Feel free to open issues at https://github.com/tbreloff/Plots.jl/issues with questions/requests.

@ljournot
Copy link
Author

Hi Tom. Thanks for taking care of my request. I will look at Plots over the next few days. Just in case you want to go on, please find attached our data. laurent

Data.txt

@ljournot ljournot reopened this Dec 10, 2015
@ljournot
Copy link
Author

it looks like the Gadfly backend used by Plots has an intrinsic problem with variable marker size.

Here is my script:
using DataFrames
cd("C:/Users/Laurent/Documents/LAURENT/MANIPS/Julia scripts/FairyLights")
data=readtable("Input//Data.csv");
using Plots
gadfly()
dataframes()
plot(data,:Fold_Enrichment,:Term,group=:Category,size=(500,500),
m=([:r :c :V :d],data[:Gene_Count]/10),mc=[RGB{U8}(1,0,0) RGB{U8}(0,1,0) RGB{U8}(0,0,1) RGB{U8}(1,0,1)],
)

and here is the message I got 4 times (one for each Category):
WARNING: Gadfly doesn't support variable marker size... using the average: 1.902325581395

The plot is working with a fixed marker size.

@Mattriks
Copy link
Member

Mattriks commented May 1, 2017

This is an update. I've reproduced the above plot using Gadfly master: except for the size and shape scales - which hopefully will be a future development! Note I'm not sure if size was linked to area or radius in the plot above.

using DataFrames, Gadfly
# There is a link to Data.txt in the issue above
D = readtable("Data.txt", header=true)
D[D[:Weight_Fischer].>0.01, :Weight_Fischer] = 0.01

theme1 = Theme(point_size_min=2pt, point_size_max=9pt, 
    point_shapes=[square, circle, utriangle, diamond])

shapesc = Scale.shape_discrete(levels=["BP","CC","KEGG_PATHWAY","MF"])
colsc = Scale.color_continuous(colormap = Scale.lab_gradient(colorant"red",
                                colorant"orange", colorant"yellow"))

p = plot(D[end:-1:1,:], x=:Fold_Enrichment, y=:Term,  size=:Gene_Count, shape=:Category,
            color=:Weight_Fischer, Geom.point, theme1, shapesc, colsc,
            Coord.cartesian(xmin=0, xmax=22),
            Guide.colorkey("P-value") 
)

issue766b

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 a pull request may close this issue.

3 participants