Git Product home page Git Product logo

cellengine-r-toolkit's Introduction

CellEngine R API Toolkit

This project adheres to Semantic Versioning. Changes are documented in the changelog.

The master branch is now a release candidate for v1.0.0.

To install the v1.0 release candidate:

library("devtools")
install_github("cellengine/cellengine-r-toolkit")

To install the legacy v0.x version:

library("devtools")
install_github("cellengine/cellengine-r-toolkit", ref="v0.x")

Refer to the Getting Started vignette for next steps!

cellengine-r-toolkit's People

Contributors

zbjornson avatar gegnew avatar

Watchers

Job van der Zwan avatar  avatar James Cloos avatar Pier Federico Gherardini avatar  avatar

cellengine-r-toolkit's Issues

Make `byName` work with `uniquePopulationName`

From Federico Gherardini

There's no way to do this from the API currently. A helper function to do this client-side:

getPopByUniqueName <- function(uniqueName) {
  myPops <- getPopulations(experimentId)
  myPops[myPops$uniqueName %in% uniqueName,]
}

Export lookupByName helper function(s)

Request from Federico.

Our internal lookupByName function won't work out of the box because it takes an API URL as the first argument; need specializations for each resource type. Some ideas:

lookupByName("gate", "my gate's name")
lookupGateByName("my gate's name")
lookup("gate", list(name = "my gate's name")) # generic lookup fn, probably too verbose

Add `applyScaleSet` function

in addition to applyScale, we should have a function to apply an entire ScaleSet, like:

applyScaleSet = function(scaleset) {
  cols = lapply(1:nrow(scaleset), function (i) {
    channelName = scaleset[i, "channelName"]
    if (channelName %in% colnames(events)) {
      applyScale(scaleset[i, "scale"], events[, channelName])
    }
  })
  df = as.data.frame(do.call(cbind, cols))
  colnames(df) = colnames(events)
  df
}

also relevant:

col_names = vector(mode="character")
    cols <- vector(mode = "list", length = nrow(scaleset))
    for(i in 1:nrow(scaleset)) {
      channelName = scaleset[i, "channelName"]
      if (channelName %in% colnames(events)) {
        col_names <- append(col_names, channelName)
        cols[[i]] <- applyScale(scaleset[i, "scale"], events[, channelName])
      }
    }
    df = as.data.frame(do.call(cbind, cols))
    colnames(df) = col_names
    out_data = data.matrix(df)

Bulk entities retrieval returns confusing properties of each entity

When you retrieve entities in bulk (i.e. getFcsFiles), and then get a single entity from the list (see code below), then a property that is a list (like annotations) are returned as a nested list.

files = getFcsFiles(id)
f = files[1,]
f$annotations
# prints:
[[1]]
           name value
1 annotations 1     1
2  annotation 2 value

However,

f = getFcsFile(id, byName("myGreatFcsFile")
f$annotations
# prints:
           name value
1 annotations 1     1
2  annotation 2 value

Add gate tailoring recipe to cookbook

We need to make a cookbook for common tasks. One of the recipes should be for tailoring gates, which is:

res=createPolygonGate(experimentId="5dcf4551b2b26508af8e63b7", "FSC-A", "FSC-H", "my gate", c(100, 200, 300), c(100, 200, 100), tailoredPerFile=TRUE)
res2=createPolygonGate(experimentId="5dcf4551b2b26508af8e63b7", "FSC-A", "FSC-H", "my gate", c(100, 200, 300), c(100, 200, 100), tailoredPerFile=TRUE, fcsFile="Specimen_001_Donor1 24h_001.fcs", gid=res$gate$gid, createPopulation=FALSE)

Add byName functionality to deleteGates

byName does not work for deleteGates.R yet.

You could add it inside the if (!is.null(gateId)) block, but it will error out when gates are tailored (which is correct behavior -- tailored gates all have the same name), and when trying to delete compound gates (names vs name). That'd address simple usages, but no pressure to do it.

A better, long-term solution (not this PR) would be a helper function like findGateForFile(fcsFileId=NULL, gid=NULL, name=NULL) helper function that picks a gate by name and FCS file, and supports compound gate names.

return `scaleSet$scales` as a `data.frame`

It's annoying to have scaleSet$scales return a single-length nested list (see below); it would be better to return as a dataframe. This is a breaking change.

> scaleSet$scales
[[1]] # <- this is a pain
    channelName   scale.type scale.minimum scale.maximum scale.cofactor
1         FSC-A     LogScale             1        100000             NA
2         FSC-W  LinearScale             1        262144             NA
3         SSC-A ArcSinhScale          -200        262144            150
4       Ax488-A ArcSinhScale          -200        262144            150

Add functionality to get experiment by name

It would be nice to have a way to get experiments by name in the functions that require an experimentId parameter, similar to the way you can get parent populations by name when creating gates.

Test `flowCore` utility functions in CI

These are currently skipped:

══ Skipped ═════════════════════════════════════════════════════════════════════
1. fromFlowCore accepts `gid` as a splat keyword arg and passes it to the next function (test-convertFromFlowCore.R:6:3) - Reason: flowCore cannot be loaded
...

consistently return fcsFileId from getGates

Right now getGates does not return the fcsFileId column if a gate is tailored but has not actually being tailored yet. This makes working with the return value more complicated. It'd be best to have the fcsFileId column to always be there

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.