GithubHelp home page GithubHelp logo

Comments (5)

gszep avatar gszep commented on September 24, 2024

maybe with using the cgrad method? https://docs.juliaplots.org/latest/generated/colorschemes/

from gigascatter.jl.

gszep avatar gszep commented on September 24, 2024
palette = cgrad(:viridis)
scale(x::Number,y::StepRangeLen) = ( x - minimum(y) )/( maximum(y) - minimum(y) )
color = map( x->palette[scale(x,channelRange)], fcsdata[!,channel] )

from gigascatter.jl.

exaexa avatar exaexa commented on September 24, 2024

Yes, this would help a lot. The scaling is now (partially) done by scaleMinMax (see README examples). Perhaps the easiest way to have that working would be to supply kwargs min/max to the scaleMinMax function that set the bounds properly. Would that work for you?

See https://github.com/LCSB-BioCore/GigaScatter.jl/blob/master/src/colors.jl#L114 for scaleMinMax.

I didn't know about cgrad, I guess I can replace a bit of the code with that, e.g. this https://github.com/LCSB-BioCore/GigaScatter.jl/blob/master/src/colors.jl#L28 .

from gigascatter.jl.

gszep avatar gszep commented on September 24, 2024

I realised that calling palette(::Float64) is 10x slower than palette(::Int64) and therefore it makes sense to pre-compute color indexes for each event. Here is the snippet I am working with:

channelRange, nlevels = range(-2,7,length=50), 10
palette = cgrad(:viridis,nlevels,categorical=true)

channels = names(fcsdata)
channel = Observable(first(channels))

function toIndex(x::AbstractVector{<:Number})
    min,max = extrema(channelRange)
    scaled = ( x .- min ) / ( max - min )
    
    @. scaled[scaled<0] = 0
    @. scaled[1<scaled] = 1
    
    return @. trunc(Int,nlevels*scaled) + 1
end

colorIndex = combine(fcsdata,[ col => toIndex => col for col  names(fcsdata) ] )
color = Observable(palette[ colorIndex[!,channel[]] ])

############################# update on channel change
on(channel) do channel
    color[] = palette[ colorIndex[!,channel] ]
end

here color[] is a Vector{RGBA{Float64}} which is a good input for the color kwarg in Makie.jl. Is it also suitable for GigaScatter.jl?

from gigascatter.jl.

exaexa avatar exaexa commented on September 24, 2024

the slowness is quite likely because the float version is doing the interpolation with all colors; I guess I can do the same with our ColorPalette. I'll likely get to it tomorrow.

from gigascatter.jl.

Related Issues (10)

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.