Skip to content

Commit

Permalink
Commit made by the Bioconductor Git-SVN bridge.
Browse files Browse the repository at this point in the history
Consists of 2 commit(s).

Commit information:

    Commit id: e8921d5
    Commit message:
    Fix some small bugs that snuck into COMPASSContainerFromGatingSet, start optimizing re: #29
    Committed by Kevin Ushey <kevinushey at gmail.com>
    Commit date: 2014-03-26T11:58:46-07:00

    Commit id: 1bbd026
    Commit message:
    Merge branch 'master' of https://github.com/RGLab/COMPASS
    Committed by Kevin Ushey <kevinushey at gmail.com>
    Commit date: 2014-03-26T11:58:55-07:00

From: Bioconductor Git-SVN Bridge <[email protected]>

git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/COMPASS@87956 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information
k.ushey committed Mar 26, 2014
2 parents b4215fb + 1bbd026 commit 21990d9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
4 changes: 2 additions & 2 deletions R/GatingSetToCOMPASS.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@ COMPASSContainerFromGatingSet <- function(gs = NULL, node = NULL, filter.fun = N
map <- map[markers, ]
}
message("We will map the following nodes to markers:")
kable(map)
kable(as.data.frame(map))


# construct the map
mp <- map[, desc]
mp <- as.character(map[, desc])
names(mp) <- map[, node]
mp <- as.list(mp)
}
Expand Down
9 changes: 4 additions & 5 deletions R/GetThresholdedIntensities.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ GetThresholdedIntensities <- function(gs, node, map) {

## Try to guess whether we should be pulling names from the 'desc'
## column or the 'name' column of the flowSets
dat <- flowWorkspace::getData(gs, use.exprs=FALSE)
ff <- get( objects(dat@frames)[[1]], envir=dat@frames )
ff <- flowWorkspace::getData(gs[[1]], use.exprs=FALSE)
params <- parameters(ff)@data

## First, check for a perfect match using a basic regex
Expand Down Expand Up @@ -151,9 +150,9 @@ GetThresholdedIntensities <- function(gs, node, map) {
} else {
node_path <- file.path(path, cNode)
}
gate <- flowWorkspace::getGate(x, node_path)
thresh <- gate@min
exprs[, expr_nms[i]][ exprs[, expr_nms[i]] < thresh ] <- 0
## find out what cells didn't fall into the gate
ind <- !flowWorkspace::getIndices(x, node_path)
exprs[ind, expr_nms[i]] <- 0
}
exprs <- exprs[ rowSums(exprs) > 0, , drop=FALSE]
return(exprs)
Expand Down
24 changes: 22 additions & 2 deletions examples/GetThresholdedIntensities.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,25 @@ if (require(flowWorkspace)) {
fs <- flowSet( lapply(data, flowFrame) )
gs <- GatingSet(fs)

## Add some dummy metadata
meta <- pData(gs)
meta$PTID <- 1:10
pData(gs) <- meta

gate <- rectangleGate( list(TNFa=c(-Inf,Inf)))
add(gs, gate, parent="root", name="dummy")

## Add dummy gate

## Make some gates, and apply them
invisible(lapply(marker_names, function(marker) {
.gate <- setNames( list( c( rexp(1, runif(1, 1E-5, 1E-3)), Inf) ), marker )
gate <- rectangleGate(.gate=.gate)
add(gs, gate, parent="root", name=paste0(marker, "+"))
add(gs, gate, parent="dummy", name=paste0(marker, "+"))
}))

recompute(gs)

## Map node names to channel names
map=list(
"TNFa+"="TNFa",
Expand All @@ -44,7 +56,15 @@ if (require(flowWorkspace)) {
)

## Pull out the data as a COMPASS-friendly dataset
output <- GetThresholdedIntensities(gs, "root", map)
node <- "dummy"
map <- map
system.time(
output <- GetThresholdedIntensities(gs, "dummy", map)
)

system.time(
output <- COMPASSContainerFromGatingSet(gs, "dummy", individual_id="PTID", sample_id="name")
)
str(output)

}
24 changes: 22 additions & 2 deletions man/GetThresholdedIntensities.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,25 @@ if (require(flowWorkspace)) {
fs <- flowSet( lapply(data, flowFrame) )
gs <- GatingSet(fs)

## Add some dummy metadata
meta <- pData(gs)
meta$PTID <- 1:10
pData(gs) <- meta

gate <- rectangleGate( list(TNFa=c(-Inf,Inf)))
add(gs, gate, parent="root", name="dummy")

## Add dummy gate

## Make some gates, and apply them
invisible(lapply(marker_names, function(marker) {
.gate <- setNames( list( c( rexp(1, runif(1, 1E-5, 1E-3)), Inf) ), marker )
gate <- rectangleGate(.gate=.gate)
add(gs, gate, parent="root", name=paste0(marker, "+"))
add(gs, gate, parent="dummy", name=paste0(marker, "+"))
}))

recompute(gs)

## Map node names to channel names
map=list(
"TNFa+"="TNFa",
Expand All @@ -77,7 +89,15 @@ if (require(flowWorkspace)) {
)

## Pull out the data as a COMPASS-friendly dataset
output <- GetThresholdedIntensities(gs, "root", map)
node <- "dummy"
map <- map
system.time(
output <- GetThresholdedIntensities(gs, "dummy", map)
)

system.time(
output <- COMPASSContainerFromGatingSet(gs, "dummy", individual_id="PTID", sample_id="name")
)
str(output)

}
Expand Down

0 comments on commit 21990d9

Please sign in to comment.