wsx_get_keywords: Get keywords from a flowjo workspace

View source: R/wsx_get_keywords.R

wsx_get_keywordsR Documentation

Get keywords from a flowjo workspace

Description

Keywords that are annotated in a flowjo workspace only exist in that very workspace. They are not hard-coded into the respective FCS files, as long as you do not re-export them. This behavior is part of flowjos philosophy not to alter the FCS files. So, the keywords that you add in workspace are like a mask on top of entries in the FCS files. When the workspace is lost though or the connection of samples in the workspace and FCS files gets corrupted your keyword-annotation is lost. Also, when you decide to put the same FCS files into another workspace the keywords will not be transferred.

Usage

wsx_get_keywords(
  ws,
  return_type = c("data.frame", "vector"),
  lapply_fun = lapply,
  keywords = NULL,
  ...
)

Arguments

ws

a path to a workspace or a the parsed xml document (xml2::read_xml(ws))

return_type

how to return keywords: data.frame with 2 column or named vector?

lapply_fun

function name without quotes; lapply, pbapply::pblapply or parallel::mclapply are suggested

keywords

which keywords to return

...

... additional argument to the lapply function; mainly mc.cores when parallel::mclapply is chosen

Value

a list of data.frames. one list entry for each sample, each row of data.frame representing one keyword

Examples

## Not run: 
# ws is the path to a flowjo workspace to extract keywords from
k <- fcexpr:::wsx_get_keywords(ws)
# make it a data.frame
kk <- do.call(rbind, k)
# create a FileName-column
kk$FileName <- rep(names(k), sapply(k,nrow))
# do not use kk$FileName <- rownames(kk) as rownames have a suffix to make them unique
# select keywords and make it a wider data.frame for subsequent joining with the sampledescription
kk <- kk[which(kk$name %in% c("$CYT", "$OP")),]
kk <- tidyr::pivot_wider(kk, names_from = name, values_from = value)
# make valid column names (general)
names(kk) <- make.names(names(kk))
# or in this special case
names(kk) <- gsub("\\$", "", names(kk))
# sd is your sampledescription
sd <- dplyr::left_join(sd, kk, by = "FileName")

## End(Not run)

Close-your-eyes/fcexpr documentation built on Sept. 29, 2023, 12:27 a.m.