Encoding: UTF-8
Type: Package
Title: Tools for Imaging Flow Cytometry
Version: 0.2.1
Date: 2023-09-13
Maintainer: Yohann Demont <git.demont@gmail.com>
BugReports: https://github.com/gitdemont/IFC/issues
Description: Contains several tools to treat imaging flow cytometry data from 'ImageStream®' and 'FlowSight®' cytometers ('Amnis®' 'Cytek®'). Provides an easy and simple way to read and write .fcs, .rif, .cif and .daf files. Information such as masks, features, regions and populations set within these files can be retrieved for each single cell. In addition, raw data such as images stored can also be accessed. Users, may hopefully increase their productivity thanks to dedicated functions to extract, visualize, manipulate and export 'IFC' data. Toy data example can be installed through the 'IFCdata' package of approximately 32 MB, which is available in a 'drat' repository https://gitdemont.github.io/IFCdata/. See file 'COPYRIGHTS' and file 'AUTHORS' for a list of copyright holders and authors.
Copyright: file inst/COPYRIGHTS
License: GPL-3
Depends: R (≥ 3.4.0)
Imports: Rcpp (≥ 0.10.0), xml2, utils, grid, gridExtra, gridGraphics, lattice, latticeExtra, KernSmooth, DT, visNetwork
Suggests: IFCdata, shiny, reticulate, png, tiff, jpeg
LinkingTo: Rcpp
Additional_repositories: https://gitdemont.github.io/IFCdata/
RoxygenNote: 7.1.1
NeedsCompilation: yes
Packaged: 2023-09-13 14:58:28 UTC; Amnis
Author: Yohann Demont [aut, cre], Gautier Stoll [ctb], Guido Kroemer [ldr], Jean-Pierre Marolleau [ldr], Loïc Garçon [ldr]
Repository: CRAN
Date/Publication: 2023-09-13 22:32:33 UTC

Tools for Imaging Flow Cytometry

Description

Contains several tools to treat Imaging Flow Cytometry data from ImageStream(R) and FlowSight(R) cytometers (Amnis(R) Cytek(R)). Provides an easy and simple way to read or write .fcs, .rif, .cif and .daf files. Information such as masks, features, regions and populations set within these files can be retrieved for each single cell. In addition, raw data such as images stored can also be accessed. Users, may hopefully increase their productivity thanks to dedicated functions to extract, visualize, manipulate and export IFC data.

Details

The IFC package provides several categories of functions:
- to read / write / export / visualize:
readIFC, writeIFC, ExtractFromDAF, ExportToDAF, data_to_DAF, ExtractFromXIF, ExportToXIF, ExtractFromFCS, ExportToFCS, ExportToBATCH, BatchReport, ExportToReport, ExportToGallery, ExportToNumpy, DisplayGallery, ExtractImages_toBase64, ExtractImages_toFile, ExtractImages_toMatrix, ExtractMasks_toMatrix, objectExtract, popsNetwork, plotGraph, paletteIFC, autoplot
- to transform features values
smoothLinLog, inv_smoothLinLog
- to deeply extract information from files:
getInfo, getOffsets, getIFD, getFullTag, getAborted
- dedicated to populations:
popsCopy, popsGetObjectsIds, popsNetwork, popsRename
- for adding / removing features, regions, populations:
data_add_features, data_add_regions, data_add_pops, data_rm_features, data_rm_regions, data_rm_pops
- to allow several coercion:
buildBatch, buildFeature, buildGraph, buildPopulation, buildRegion

Author(s)

Maintainer: Yohann Demont <git.demont@gmail.com>


Batch Generation of Graphical and Statistic Report

Description

Batch creates graphical an statistical report.

Usage

BatchReport(
  fileName,
  obj,
  selection,
  write_to,
  overwrite = FALSE,
  gating,
  main,
  byrow = FALSE,
  times = 5,
  color_mode = c("white", "black")[1],
  add_key = "panel",
  precision = c("light", "full")[1],
  trunc_labels = 38,
  trans = "asinh",
  bin,
  viewport = "ideas",
  backend = "lattice",
  display_progress = TRUE,
  ...
)

Arguments

fileName, obj

either one or the other. Path to file(s) to read from for 'fileName' or list of 'IFC_data' objects for obj.

selection

indices of desired graphs. It can be provided as an integer vector or as a matrix.
In such case, the layout of the matrix will reflect the layout of the extracted graphs for each 'fileName' or ”obj'.
NA value will result in an empty place. When missing, it will be determined by the whole layout of 1st 'fileName' or 'obj' with 'gating' applied when provided

write_to

pattern used to export file(s). Placeholders, like c("%d/%s_fromR.pdf", "%d/%s_fromR.csv"), will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension).
Exported file(s) extension(s) will be deduced from this pattern using either 1st 'fileName' or 'obj'. Note that has to be a .pdf and/or .csv.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite file. In addition a warning message will be sent.

gating

an 'IFC_gating' object as extracted by readGatingStrategy(). Default is missing. If not missing, each ‘IFC_data' provided in ’obj' or read from 'fileName' will be passed to applyGatingStrategy() before creating the report.

main

the main title of the document. Default is missing.

byrow

whether to add selected graphs for each file by row or not. Default is FALSE.

times

number of files to add before starting a new row or column (depending on 'byrow').

color_mode

Whether to extract colors in white or black mode. Default is "white".

add_key

whether to draw a "global" key under title or in the first "panel" or "both". Default is "panel".
Accepted values are either: FALSE, "panel", "global", "both" or c("panel", "global").
Note that it only applies when display is seen as overlaying populations.

precision

when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light".
-"light", the default, will only display points of same coordinates that are among the other layers.
-"full" will display all the layers.

trunc_labels

maximum number of characters to display for labels. Default is 38.

trans

name of the transformation function for density graphs. If missing the default, the BasePop[[1]]$densitytrans, if any, will be retrieved, otherwise "asinh" will be used.

bin

default number of bin used for histogram. Default is missing.

viewport

Either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas".
-"ideas" will use same limits as the one defined in ideas.
-"data" will use data to define limits.
-"max" will use data and regions drawn to define limits.

backend

backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice".
-"lattice" is the original one used in IFC using lattice,
-"base" will produce the plot using base,
-"raster" uses "base" for plotting but 2D graphs points will be produced as rasterImage.
This has the main advantage of being super fast allowing for plotting a huge amount of points while generating smaller objects (in bytes). However, plot quality is impacted with "raster" method and resizing can lead to unpleasant looking.

display_progress

whether to display a progress bar. Default is TRUE.

...

other parameters to be passed.

Value

It invisibly returns full path of exported .pdf and/or .csv file(s).


Batch Generation of Statistic Report

Description

Generates statistics report on batch of files or 'IFC_data' objects.

Usage

BatchStatsReport(fileName, obj, stats, gating, display_progress = FALSE, ...)

Arguments

fileName, obj

either one or the other. Path to file(s) to read from for 'fileName' or list of 'IFC_data' objects for obj.

stats

template defining stats to compute as extracted by getSTATSREPORT().

gating

an 'IFC_gating' object as extracted by readGatingStrategy(). Default is missing. If not missing, each ‘IFC_data' provided in ’obj' or read from 'fileName' will be passed to applyGatingStrategy() before creating the report.

display_progress

whether to display a progress bar. Default is TRUE.

...

other parameters to be passed.

Value

a data.frame of statistics


Graph Report Generation

Description

Generates graph report (plot + statistics) from 'IFC_data' object.

Usage

CreateGraphReport(
  obj,
  selection,
  onepage = TRUE,
  color_mode = c("white", "black")[1],
  add_key = "panel",
  precision = c("light", "full")[1],
  trunc_labels = 38,
  trans = "asinh",
  bin,
  viewport = "ideas",
  backend = "lattice",
  display_progress = TRUE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

selection

indices of desired graphs. It can be provided as an integer vector or as a matrix.
In such case, the layout of the matrix will reflect the layout of the extracted graphs.
NA value will result in an empty place.
Otherwise, when 'selection' is provided as a vector not identical to seq_along(obj$graphs), 'onepage' parameter will be set to FALSE.
Note that indices are read from left to right, from top to bottom. Default is missing for extracting all graphs.

onepage

whether to generate a pdf with all graphs on one page or not. Default is TRUE.

color_mode

Whether to extract colors from obj in white or black mode. Default is "white".

add_key

whether to draw a "global" key under title or in the first "panel" or "both". Default is "panel".
Accepted values are either: FALSE, "panel", "global", "both" or c("panel", "global").
Note that it only applies when display is seen as overlaying populations.

precision

when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light".
-"light", the default, will only display points of same coordinates that are among the other layers.
-"full" will display all the layers.

trunc_labels

maximum number of characters to display for labels. Default is 38.

trans

name of the transformation function for density graphs. If missing the default, the BasePop[[1]]$densitytrans, if any, will be retrieved, otherwise "asinh" will be used.

bin

default number of bin used for histogram. Default is missing.

viewport

Either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas".
-"ideas" will use same limits as the one defined in ideas.
-"data" will use data to define limits.
-"max" will use data and regions drawn to define limits.

backend

backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice".
-"lattice" is the original one used in IFC using lattice,
-"base" will produce the plot using base,
-"raster" uses "base" for plotting but 2D graphs points will be produced as rasterImage.
This has the main advantage of being super fast allowing for plotting a huge amount of points while generating smaller objects (in bytes). However, plot quality is impacted with "raster" method and resizing can lead to unpleasant looking.

display_progress

whether to display a progress bar. Default is TRUE.

...

other parameters to be passed.

Value

a list with onepage, layout, layout_matrix, graphs, grobs, and stats.


Gallery Display

Description

Displays gallery of 'IFC_img' / 'IFC_msk' objects

Usage

DisplayGallery(
  ...,
  objects,
  offsets,
  image_type = "img",
  layout,
  name = "DisplayGallery",
  caption = FALSE,
  pageLength = 10L,
  pdf_pageSize = "A2",
  pdf_pageOrientation = "landscape",
  pdf_image_dpi = 96,
  extract_max = 10,
  sampling = FALSE,
  display_progress = TRUE,
  mode = c("rgb", "gray")[1]
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
If 'param' is provided 'export'(="base64") and the above parameters will be overwritten.
If 'offsets' are not provided extra arguments can also be passed with ... to getOffsets.
/!\ If not any of 'fileName', 'info' and 'param' can be found in ... then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.

image_type

image_type of desired offsets. Either "img" or "msk". Default is "img".

layout

a character vector of [acquired channels + 'composite' images] members to export. Default is missing to export everything.
Note that members can be missing to be removed from final display.
Note that members not found will be automatically removed and a warning will be thrown.

name

id of the datatable container. Default is DisplayGallery.

caption

whether to display caption name or not. Default is FALSE.

pageLength

integer, number of objects to display per page. Default is 10.

pdf_pageSize

string, page dimension when exporting to pdf. Default is "A2".

pdf_pageOrientation

string, page orientation when exporting to pdf. Default is "landscape". Allowed are "landscape" or "portrait".

pdf_image_dpi

integer, desired image resolution. Default is 96, for full resolution.

extract_max

maximum number of objects to extract. Default is 10. Use +Inf to extract all.

sampling

whether to sample objects or not. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

mode

(objectParam argument) color mode export. Either "rgb" or "gray". Default is "rgb".

Details

arguments of objectExtract will be deduced from DisplayGallery input arguments.
Please note that PDF export link will be available if 'write_to' will not result in a "bmp".
Please note that exporting to "tiff" may depend on browser capabilities.
Please note that a warning may be sent if gallery to display contains large amount of data. This is due to use of datatable() from DT.
Warning message:
In instance$preRenderHook(instance) :
It seems your data is too big for client-side DataTables. You may consider server-side processing: http://rstudio.github.io/DT/server.html
For these reasons, it may be better to use "png" extension to display images.

Value

it invisibly returns a list whose members are:
-data, data for DT::datatable(),
-args, associated arguments to pass to DT::datatable().

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  cif <- ExtractFromXIF(fileName = file_cif)
  info <- getInfo(fileName = file_cif, from = "analysis")
  ## randomly show at most 10 "img" objects from file
  DisplayGallery(info = info, image_type = "img", extract_max = 10,
                 sampling = TRUE, write_to = "example.bmp")
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Graphical and Statistic Report Display

Description

Displays report from 'IFC_data' object.

Usage

DisplayReport(obj, display_progress = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

display_progress

whether to display a progress bar. Default is TRUE.

...

other parameters to be passed.

Value

It invisibly returns NULL


Batch File Writer

Description

Writes an XML file to batch files

Usage

ExportToBATCH(batch)

Arguments

batch

list of batch nodes as created by buildBatch.

Value

It invisibly returns full path of xml batch file.


DAF File Writer

Description

Writes a new DAF file based on another one and exports new region(s), pop(s), feature(s), graph(s) and / or mask(s).

Usage

ExportToDAF(
  fileName,
  write_to,
  pops = list(),
  regions = list(),
  features = list(),
  graphs = list(),
  masks = list(),
  viewing_pop = "All",
  endianness = .Platform$endian,
  verbose = FALSE,
  overwrite = FALSE,
  fullname = TRUE,
  cifdir = dirname(fileName),
  ntry = +Inf,
  ...
)

Arguments

fileName

path of file to read data from.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'fileName'
-%p: with first parent directory of 'fileName'
-%e: with extension of 'fileName' (without leading .)
-%s: with shortname from 'fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that has to be a .daf.

pops

list of population(s) to export. Will be coerced to exportable format by buildPopulation.

regions

list of region(s) to export. Will be coerced to exportable format by buildRegion.

features

list of feature(s) to export.

graphs

list of graph(s) to export. Not yet implemented.

masks

list of mask(s) to export. Not yet implemented.

viewing_pop

Character String. Allow user to change displayed population. Default is 'All'.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite exported file if path of 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten.
Otherwise, you will get an error saying that overwriting original file is not allowed.

fullname

whether to export daf file with full name of its corresponding cif, if found. Default is TRUE. If cif can't be found, daf file will be exported with the original cif file name.

cifdir

the path of the directory to initially look to cif file. Default is dirname(fileName). Only apply when 'fullname' is set to TRUE.

ntry

number of times ExportToDAF will be allowed to find corresponding cif file. Default is +Inf. Only apply when 'fullname' is set to TRUE.

...

other arguments to be passed.

Value

It invisibly returns full path of exported file.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  tmp <- tempdir(check = TRUE)
  ## create a tagged population named test with 1st object
  pop <- buildPopulation(name = "test", type = "T", obj = 0)
  ExportToDAF(file_daf, write_to = paste0(tmp, "\\test.daf"),
              overwrite = TRUE, pops = list(pop))
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

FCS File Writer

Description

Writes an 'IFC_data' object to a Flow Cytometry Standard (FCS) file.

Usage

ExportToFCS(
  obj,
  write_to,
  overwrite = FALSE,
  delimiter = "/",
  cytometer = "Image Stream",
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'obj$fileName'
-%p: with first parent directory of 'obj$fileName'
-%e: with extension of 'obj$fileName' (without leading .)
-%s: with shortname from 'obj$fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that it has to be a .fcs.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite exported file if path of 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file will never be overwritten.

delimiter

an ASCII character to separate the FCS keyword-value pairs. Default is : "/".

cytometer

string, if provided it will be used to fill $CYT keyword.
However, when missing $CYT will be filled with obj$description$FCS$instrument if found, or "Image Stream" otherwise.

...

other arguments to be passed. keyword-value pairs can be passed here.

Value

invisibly returns full path of exported file.


Gallery Export

Description

Exports gallery of 'IFC_img' / 'IFC_msk' objects

Usage

ExportToGallery(
  ...,
  objects,
  offsets,
  image_type = "img",
  layout,
  export = c("file", "matrix", "base64")[2],
  write_to,
  base64_id = FALSE,
  base64_att = "",
  overwrite = FALSE,
  main = "",
  add_channels = TRUE,
  add_ids = 1,
  add_lines = 2,
  bg_color = "grey20",
  dpi = 300,
  scale = list(),
  extract_max = 10,
  sampling = FALSE,
  display_progress = TRUE
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
If 'param' is provided 'mode'(="rgb") and the above parameters will be overwritten.
If 'offsets' are not provided extra arguments can also be passed with ... getOffsets.
/!\ If not any of 'fileName', 'info' and 'param' can be found in ... then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.

image_type

image_type of desired offsets. Either "img" or "msk". Default is "img".

layout

a character vector of [acquired channels + 'composite' images] members to export. Default is missing to export everything. Note that members can be missing to be removed from final gallery export. Note that members not found will be automatically removed and a warning will be thrown.

export

export format. Either "file", "matrix", "base64". Default is "matrix".

write_to

used when 'export' is "file" or "base64" to compute respectively filename or base64 id attribute. Exported type will be deduced from this pattern. Allowed export are '.bmp', '.jpg', '.jpeg', '.png', '.tif', '.tiff'. Note that '.bmp' are faster but not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with objects (at most 10, will be collapse with "_", if more than one).
-%c: with channel_id (will be collapse with "_", if more than one, composite in any will be bracketed). A good trick is to use:
-"%d/%s_gallery_Obj[%o]_Ch[%c].tiff", when 'export' is "file"
-"%s_gallery.bmp", when 'export' is "base64".
Note that if missing and 'export' is not "file", 'write_to' will be set to "%s_gallery.bmp".

base64_id

whether to add id attribute to base64 exported object. Default is TRUE.
Only applied when 'export' is "base64".

base64_att

attributes to add to base64 exported object. Default is "".
Only applied when export is "base64". For example, use "class=draggable".
Note that id (if base64_id is TRUE) and width and height are already used.

overwrite

whether to overwrite file or not. Default is FALSE.

main

main title that will be displayed on top center of the image. If too large it will be clipped.

add_channels

whether to add channels names. Default is TRUE.

add_ids

integer, indice of column to mark objects ids number. Default is 1. If add_ids < 1, no ids are added.

add_lines

integer, size of separating lines between objects. Default is 1. If add_lines < 1, no separating lines are added.

bg_color

background color for main, channels and separating lines. Default is "grey20".

dpi

integer, the resolution of the image in DPI (dots per inch). Default is 300.
Please note that whetever this parameter is final resolution will be 96 dpi.
However image will be scaled according this parameter and magnification factor will be equal to this parameter divided by 96.

scale

a named list whose members are 'size', 'style', 'color', 'xoff', 'yoff'. Default is list() to draw no scale. Otherwise,
-'size' positive integer. Scale's bar size in micro-meter. Default is '7'.
This parameter can't be lesser than 6px nor higher than image width + scale text.
-'style' a character string. Scale's bar style, either "dash" or "line". Default is "dash".
-'color' a character string. color of the scale. Default is "white".
-'xoff' positive integer. x offset in image to draw scale, starting from bottom left corner.
-'yoff' positive integer. y offset in image to draw scale, starting from bottom left corner.

extract_max

maximum number of objects to extract. Default is 10. Use +Inf to extract all.

sampling

whether to sample objects or not. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

Details

arguments of objectExtract will be deduced from ExportToGallery input arguments. TRICK: for exporting only ONE 'objects', set 'add_channels' = FALSE, 'add_ids' >= 1, 'force_width' = FALSE, 'dpi' = 96; this allows generating image with its original size incrusted with its id number.

Value

Depending on 'export':
-"matrix", a rgb array,
-"base64", a data-uri string,
-"file", an invisible vector of ids corresponding to the objects exported.


Numpy Export

Description

Exports IFC objects to numpy array [objects,height,width,channels]

Usage

ExportToNumpy(
  ...,
  objects,
  offsets,
  image_type = "img",
  size = c(64, 64),
  force_width = FALSE,
  display_progress = TRUE,
  python = Sys.getenv("RETICULATE_PYTHON"),
  dtype = c("uint8", "int16", "uint16", "double")[3],
  mode = c("raw", "gray")[1],
  export = c("file", "matrix")[2],
  write_to,
  overwrite = FALSE
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

image_type

type of desired object offsets. Either "img" or "msk". Default is "img".

size

a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(64,64).

force_width

whether to use information in 'info' to fill 'size'. Default is FALSE. When set to TRUE, width of 'size' argument will be overwritten.

display_progress

whether to display a progress bar. Default is TRUE.

python

path to python. Default is Sys.getenv("RETICULATE_PYTHON").
Note that numpy should be available in this python to allow export to ".npy" file, otherwise 'export' will be forced to "matrix".

dtype

desired arrays data-type. Default is "double". Allowed are "uint8", "int16", "uint16" or "double". If 'mode' is "raw", this parameter will be forced to "int16".

mode

(objectParam argument) color mode export. Either "raw", "gray". Default is "raw".

export

export format. Either "file", "matrix". Default is "matrix".
Note that you will need reticulate package installed to be able to export to ".npy" file, otherwise 'export' will be forced to "matrix".

write_to

used when 'export' is "file" to compute exported file name and type. Exported type will be deduced from this pattern. Allowed exported file extension is ".npy".
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension of (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with objects (at most 10, will be collapse with "_", if more than one).
-%c: with channel_id (will be collapse with "_", if more than one, composite in any will be bracketed). A good trick is to use:
-"%d/%s_Obj[%o]_Ch[%c].npy", when 'export' is "file".

overwrite

whether to overwrite file or not. Default is FALSE.

Details

Please note that 'size' parameter has to be supplied and could not be set to (0,) when 'object' length is not equal to one
ExportToNumpy requires reticulate package, python and numpy installed to create ".npy" file.
If one of these is missing, 'export' will be set to "matrix". If 'param' is provided in '...', param$export <- "matrix", param$mode <- 'mode' and param$size <- 'size' and will be overwritten.

Value

Depending on 'export':
-"matrix", an array whose dimensions are [object, height, width, channel].
-"file", it invisibly returns path of ".npy" exported file.

Note

Arguments of objectExtract will be deduced from ExportToNumpy input arguments.


Graphical and Statistic Report Generation

Description

Generates report from 'IFC_data' object.

Usage

ExportToReport(
  obj,
  selection,
  write_to,
  overwrite = FALSE,
  onepage = TRUE,
  color_mode = c("white", "black")[1],
  add_key = "panel",
  precision = c("light", "full")[1],
  trunc_labels = 38,
  trans = "asinh",
  bin,
  viewport = "ideas",
  backend = "lattice",
  display_progress = TRUE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

selection

indices of desired graphs. It can be provided as an integer vector or as a matrix.
In such case, the layout of the matrix will reflect the layout of the extracted graphs.
NA value will result in an empty place.
Otherwise, when 'selection' is provided as a vector not identical to seq_along(obj$graphs), 'onepage' parameter will be set to FALSE.
Note that indices are read from left to right, from top to bottom. Default is missing for extracting all graphs.

write_to

pattern used to export file(s). Placeholders, like c("%d/%s_fromR.pdf", "%d/%s_fromR.csv"), will be substituted:
-%d: with full path directory of 'obj$fileName'
-%p: with first parent directory of 'obj$fileName'
-%e: with extension of 'obj$fileName' (without leading .)
-%s: with shortname from 'obj$fileName' (i.e. basename without extension).
Exported file(s) extension(s) will be deduced from this pattern. Note that has to be a .pdf and/or .csv.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite file. In addition a warning message will be sent.

onepage

whether to generate a pdf with all graphs on one page or not. Default is TRUE.

color_mode

Whether to extract colors from obj in white or black mode. Default is "white".

add_key

whether to draw a "global" key under title or in the first "panel" or "both". Default is "panel".
Accepted values are either: FALSE, "panel", "global", "both" or c("panel", "global").
Note that it only applies when display is seen as overlaying populations.

precision

when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light".
-"light", the default, will only display points of same coordinates that are amoung the other layers.
-"full" will display all the layers.

trunc_labels

maximum number of characters to display for labels. Default is 38.

trans

name of the transformation function for density graphs. If missing the default, the BasePop[[1]]$densitytrans, if any, will be retrieved, otherwise "asinh" will be used.

bin

default number of bin used for histogram. Default is missing.

viewport

Either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas".
-"ideas" will use same limits as the one defined in ideas.
-"data" will use data to define limits.
-"max" will use data and regions drawn to define limits.

backend

backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice".
-"lattice" is the original one used in IFC using lattice,
-"base" will produce the plot using base,
-"raster" uses "base" for plotting but 2D graphs points will be produced as rasterImage.
This has the main advantage of being super fast allowing for plotting a huge amount of points while generating smaller objects (in bytes). However, plot quality is impacted with "raster" method and resizing can lead to unpleasant looking.

display_progress

whether to display a progress bar. Default is TRUE.

...

other parameters to be passed.

Details

depending on 'write_to', function will create .pdf and/or .csv file(s) report with according to graphs found in 'obj'.
- csv file if created will contain "Min.","1st Qu.","Median","Mean","3rd Qu.","Max." for each graph found for x and y (if not histogram) for drawn populations and regions.
- pdf file if created will contain graphs and to a certain extent some stats "Min.", "Median", "Mean", "Max." (no more than 7 rows).
Note that only graphs will be exported (no images, features values, population stats, ...) in the same layout they were created and without sizing.

Value

It invisibly returns full path of exported .pdf and/or .csv file(s).

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  tmp <- tempdir(check = TRUE)
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf, extract_images = FALSE,
                        extract_offsets = FALSE, display_progress = FALSE)
  L = length(daf$graphs)
  if(L > 0) { 
    ## randomly export at most 5 graphs from daf
    sel = sample(1:L, min(5, L))
    ExportToReport(obj = daf, selection = sel,
                   write_to = paste0(tmp, "\\test.pdf"), overwrite = TRUE)
  }
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

RIF/CIF File Writer

Description

Subsets or merges RIF or CIF files.

Usage

ExportToXIF(
  fileName,
  write_to,
  objects,
  offsets,
  fast = TRUE,
  extract_features = FALSE,
  endianness = .Platform$endian,
  verbose = FALSE,
  verbosity = 1,
  overwrite = FALSE,
  display_progress = TRUE,
  add_tracking = TRUE,
  ...
)

Arguments

fileName

path(s) of file(s) to subset or merge. If multiple files are provided they will be merged. Otherwise, if only one file is input it will be subsetted. All files have to be either '.rif' or '.cif' files. All files should have same channels.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of first element of 'fileName'
-%p: with first parent directory of first element of 'fileName'
-%e: with extension of first element of 'fileName' (without leading .)
-%s: with shortname from of first element of 'fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. It has to be the same as 'fileName', i.e. .cif or .rif.

objects

integer vector, IDEAS objects ids numbers to use. If missing, the default, all objects will be used. Only apply for subsetting.

offsets

object of class ‘IFC_offset'. If missing, the default, offsets will be extracted from ’fileName'.
This param is not mandatory but it may allow to save time for repeated XIF export on same file. Only apply for subsetting.

fast

whether to fast extract 'objects' or not. Default is TRUE. Meaning that 'objects' will be extracted expecting that 'objects' are stored in ascending order.
Note that a warning will be sent if an 'object' is found at an unexpected order. In such a case you may need to rerun function with 'fast' = FALSE. If set to FALSE, all object_ids will be scanned from 'fileName' to ensure extraction of desired 'objects'.
IMPORTANT: whatever this argument is, features are extracted assuming an ascending order of storage in file.
Only apply for subsetting.

extract_features

whether to try to extract features. Default is FALSE. IMPORTANT: it is not clear if how features are stored and which objects they rely to when input file is already a merge or a subset. For this reason it should be carefully checked. Note that features extraction is not implemented for merging.

endianness

the endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

overwrite

whether to overwrite file or not. Default is FALSE.
Note that if TRUE, it will overwrite exported file if path(s) of file(s) in 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

display_progress

whether to display a progress bar. Default is TRUE.

add_tracking

whether to register files' paths and objects' ids in the exported file. Default is TRUE.

...

other arguments to be passed.

Details

when 'extract_features' is set TRUE, only features stored in binary format will be extracted if found.
If the input 'fileName' is a merged of several files then features will be extracted from these files.
If these files can't be found, Warning(s) will be thrown and input 'fileName' will be extracted without features values.

Value

It invisibly returns full path of exported file.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  tmp <- tempdir(check = TRUE)
  ## use a cif file, but you can also subset rif
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  ## subset objects 0,1 and 4 from file
  exported <- ExportToXIF(fileName = file_cif, write_to = paste0(tmp, "\\test.cif"),
                          overwrite = TRUE, objects = c(0,1,4))
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

DAF File Reader

Description

Extracts data from DAF Files.

Usage

ExtractFromDAF(
  fileName,
  extract_features = TRUE,
  extract_images = TRUE,
  extract_offsets = TRUE,
  extract_stats = TRUE,
  endianness = .Platform$endian,
  pnt_in_poly_algorithm = 1,
  pnt_in_poly_epsilon = 1e-12,
  display_progress = TRUE,
  ...
)

Arguments

fileName

path to file.

extract_features

whether to extract features (and graphs, pops and regions) from file. Default is TRUE.

extract_images

whether to extract images information from file. Default is TRUE.

extract_offsets

whether to extract IFDs offsets from corresponding. Default is TRUE.
See getOffsets for further details.

extract_stats

whether to extract population statistics. Default is TRUE.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

pnt_in_poly_algorithm

algorithm used to determine if object belongs to a polygon region or not. Default is 1.
Note that for the moment only 1(Trigonometry) is available.

pnt_in_poly_epsilon

epsilon to determine if object belongs to a polygon region or not. It only applies when algorithm is 1. Default is 1e-12.

display_progress

whether to display a progress bar. Default is TRUE.

...

Other arguments to be passed.

Details

When extract_features is TRUE it allows features, graphs, pops, regions to be extracted.
If extract_features is TRUE, extract_stats will be automatically forced to TRUE.
If extract_stats is TRUE, extract_features will be automatically forced to TRUE.
If extract_offsets is TRUE, extract_images will be automatically forced to TRUE.
If extract_images is TRUE, information about images will be extracted.

Value

A named list of class 'IFC_data', whose members are:
-description, a list of descriptive information,
-fileName, path of fileName input,
-fileName_image, path of .cif image fileName is refering to,
-features, a data.frame of features,
-features_def, a describing how features are defined,
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined,
-images, a data.frame describing information about images,
-offsets, an integer vector of images and masks IFDs offsets,
-stats, a data.frame describing populations count and percentage to parent and total population,
-checksum, checksum of .cif image fileName is refering to computed from images values found in current daf.

Source

For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

FCS File Reader

Description

Extracts data from Flow Cytometry Standard (FCS) Files.

Usage

ExtractFromFCS(fileName, ...)

Arguments

fileName

path(s) of file(s). If multiple files are provided they will be merged and populations will be created to identify each single file within returned 'IFC_data' object.

...

other arguments to be passed to readFCS function, with the exception of 'options$text_only'.

Value

A named list of class 'IFC_data', whose members are:
-description, a list of descriptive information,
-Merged_fcs, character vector of path of files used to create fcs, if input was a merged,
-Keywords, a named-list of keywords values, only keywords from 1st 'fcs' segment will be retrieved
-fileName, path of fileName input,
-fileName_image, path of .cif image fileName is referring to,
-features, a data.frame of features,
-features_def, a describing how features are defined,
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined,
-images, a data.frame describing information about images,
-offsets, an integer vector of images and masks IFDs offsets,
-stats, a data.frame describing populations count and percentage to parent and total population,
-checksum, a checksum integer.

Source

Data File Standard for Flow Cytometry, version FCS 3.1 from Spidlen J. et al. available at doi: 10.1002/cyto.a.20825.


RIF/CIF File Reader

Description

Extracts data from RIF or CIF Files.

Usage

ExtractFromXIF(
  fileName,
  extract_features = TRUE,
  extract_images = FALSE,
  extract_offsets = FALSE,
  extract_stats = TRUE,
  pnt_in_poly_algorithm = 1,
  pnt_in_poly_epsilon = 1e-12,
  force_default = TRUE,
  verbose = FALSE,
  verbosity = 1,
  display_progress = TRUE,
  fast = TRUE,
  recursive = FALSE,
  ...
)

Arguments

fileName

path to file.

extract_features

whether to extract features from file. Default is TRUE.
If TRUE, ExtractFromXIF will try to export features. It it fails a message will be sent.
Otherwise, graphs, pops and regions will be also extracted.

extract_images

whether to extract images information from file. Default is FALSE.

extract_offsets

whether to extract IFDs offsets from corresponding. Default is FALSE.
See getOffsets for further details.

extract_stats

whether to extract population statistics. Default is TRUE.

pnt_in_poly_algorithm

algorithm used to determine if object belongs to a polygon region or not. Default is 1.
Note that for the moment only 1(Trigonometry) is available.

pnt_in_poly_epsilon

epsilon to determine if object belongs to a polygon region or not. It only applies when algorithm is 1. Default is 1e-12.

force_default

when display information can't be retrieved whether to use default values. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

display_progress

whether to display a progress bar. Default is TRUE.

fast

whether to fast extract 'objects' or not. Default is TRUE.
Meaning that offsets will be extracted expecting that 'objects' are stored in ascending order. if extract_images is FALSE, a message will be thrown since extraction method does not ensure correct mapping between objects and offsets.
if extract_images is TRUE, a warning will be sent if an object is found at an unexpected order.

recursive

whether to recursively apply ExtractFromXIF on files defining input fileName when it is a merged. Default is FALSE.

...

Other arguments to be passed.

Details

If extract_stats is TRUE, extract_features will be automatically forced to TRUE.
If extract_images is TRUE, extract_offsets will be automatically forced to TRUE.
If extract_offsets is TRUE, offsets of images and masks IFDs will be extracted.
If extract_images is TRUE, information about images will be extracted.
If the input fileName is a merged of several files and recursive is set to TRUE, then ExtractFromXIF will be applied recursively on these files.
/!\ Note that features extraction is mandatory to correctly extract graphs, pops, regions and statistics values.

Value

A named list of class 'IFC_data', whose members are:
-description, a list of descriptive information,
-fileName, path of fileName input,
-fileName_image, same as fileName,
-features, a data.frame of features,
-features_def, a describing how features are defined,
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined,
-images, a data.frame describing information about images,
-offsets, an integer vector of images and masks IFDs offsets,
-stats, a data.frame describing populations count and percentage to parent and total population,
-checksum, current file checksum.
If fileName is a merged of several files returned object will be of class 'IFC_data' and 'Merged'. If recursive is set to "TRUE", ExtractFromXIF will be applied recursively on files defining the merged. and the returned object will be a list of the above-mentionned list for each of these files.

Source

For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file, but you can also read rif
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  cif <- ExtractFromXIF(fileName = file_cif)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Shortcut for Batch Images Extraction to Base64

Description

Function to shortcut extraction, normalization and eventually colorization of images to base64 ! excludes mask.

Usage

ExtractImages_toBase64(
  ...,
  objects,
  offsets,
  display_progress = TRUE,
  mode = c("rgb", "gray")[1],
  write_to,
  base64_id,
  base64_att
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

mode

(objectParam argument) color mode export. Either "rgb", "gray". Default is "rgb".

write_to

used to compute respectively exported file name.
Exported base64 data-uri will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" is faster but files are not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with object_id
-%c: with channel_id
A good trick is to use: "%o_%c.bmp".

base64_id

whether to add id attribute to base64 exported object.

base64_att

attributes to add to base64 exported object.
For example, use "class='draggable'".
Note that id (if 'base64_id' is TRUE) and width and height are already used.

Details

If 'param' is provided 'in '...':
-'param$export'<-"base64" and 'param$mode'<-'mode' only will be overwritten.
-if 'write_to' is not missing, 'param$write_to'<-'write_to' will be overwritten. Otherwise, 'param$write_to' will be used.
-if 'base64_id' is not missing, 'param$base64_id'<-'base64_id' will be overwritten. Otherwise, 'param$base64_id' will be used.
-if 'base64_att' is not missing, 'param$base64_att'<-'base64_att' will be overwritten. Otherwise, 'param$base64_att' will be used.

When missing and not found 'param', default values will be used for 'write_to'(="%o_%c.bmp"), 'base64_id'(=FALSE) and 'base64_att'(="")

Value

A list of base64 encoded images corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractImages_toBase64 input arguments.


Shortcut for Batch Images Extraction to Files

Description

Function to shortcut extraction, normalization and eventually colorization of images to file ! excludes mask.

Usage

ExtractImages_toFile(
  ...,
  objects,
  offsets,
  display_progress = TRUE,
  mode = c("rgb", "gray")[1],
  write_to,
  overwrite = FALSE
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

mode

(objectParam argument) color mode export. Either "rgb", "gray". Default is "rgb".

write_to

used to compute respectively exported file name.
Exported "file" extension will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" is faster but files are not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with object_id
-%c: with channel_id
A good trick is to use: "%d/%s/%s_%o_%c.tiff".

overwrite

whether to overwrite file or not. Default is FALSE.

Details

If 'param' is provided in '...':
-'param$export'<-"file", 'param$mode'<-'mode' and 'param$overwrite'<-'overwrite' will be overwritten.
-if 'write_to' is not missing, 'param$write_to'<-'write_to' will be overwritten. Otherwise, 'param$write_to' will be used only if 'param$export' was "file".

'write_to' has to be provided if 'param' can't be found in '...' or if 'param$export' was not "file".

Value

It invisibly returns a list of exported file path of corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractImages_toFile input arguments.


Shortcut for Batch Images Extraction to Matrices/Arrays

Description

Function to shortcut extraction, normalization and eventually colorization of images to matrix ! excludes mask.

Usage

ExtractImages_toMatrix(..., objects, offsets, display_progress = TRUE)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

Details

If 'param' is provided in '...', 'param$export'<-"matrix" only will be overwritten.

Value

A list of matrices/arrays of images corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractImages_toMatrix input arguments.


Shortcut for Batch Masks Extraction to Base64

Description

Function to shortcut extraction, normalization and eventually colorization of masks to base64 ! excludes image.

Usage

ExtractMasks_toBase64(
  ...,
  objects,
  offsets,
  display_progress = TRUE,
  mode = c("rgb", "gray")[1],
  write_to,
  base64_id,
  base64_att
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

mode

(objectParam argument) color mode export. Either "rgb", "gray". Default is "rgb".

write_to

used to compute respectively exported file name.
Exported base64 data-uri will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" is faster but files are not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with object_id
-%c: with channel_id
A good trick is to use: "%o_%c.bmp".

base64_id

whether to add id attribute to base64 exported object.

base64_att

attributes to add to base64 exported object.
For example, use "class='draggable'".
Note that id (if 'base64_id' is TRUE) and width and height are already used.

Details

If 'param' is provided 'in '...':
-'param$export'<-"base64" and 'param$mode'<-'mode' only will be overwritten.
-if 'write_to' is not missing, 'param$write_to'<-'write_to' will be overwritten. Otherwise, 'param$write_to' will be used.
-if 'base64_id' is not missing, 'param$base64_id'<-'base64_id' will be overwritten. Otherwise, 'param$base64_id' will be used.
-if 'base64_att' is not missing, 'param$base64_att'<-'base64_att' will be overwritten. Otherwise, 'param$base64_att' will be used.

When missing and not found 'param', default values will be used for 'write_to'(="%o_%c.bmp"), 'base64_id'(=FALSE) and 'base64_att'(="")

Value

A list of base64 encoded images corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractMasks_toBase64 input arguments.


Shortcut for Batch Masks Extraction to Files

Description

Function to shortcut extraction, normalization and eventually colorization of masks to file ! excludes image.

Usage

ExtractMasks_toFile(
  ...,
  objects,
  offsets,
  display_progress = TRUE,
  mode = c("rgb", "gray")[1],
  write_to,
  overwrite = FALSE
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

mode

(objectParam argument) color mode export. Either "rgb", "gray". Default is "rgb".

write_to

used to compute respectively exported file name.
Exported "file" extension will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" is faster but files are not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory
-%p: with first parent directory
-%e: with extension (without leading .)
-%s: with shortname (i.e. basename without extension)
-%o: with object_id
-%c: with channel_id
A good trick is to use: "%d/%s/%s_%o_%c.tiff".

overwrite

whether to overwrite file or not. Default is FALSE.

Details

If 'param' is provided in '...':
-'param$export'<-"file", 'param$mode'<-'mode' and 'param$overwrite'<-'overwrite' will be overwritten.
-if 'write_to' is not missing, 'param$write_to'<-'write_to' will be overwritten. Otherwise, 'param$write_to' will be used only if 'param$export' was "file".

'write_to' has to be provided if 'param' can't be found in '...' or if 'param$export' was not "file".

Value

It invisibly returns a list of exported file path of corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractMasks_toFile input arguments.


Shortcut for Batch Masks Extraction to Matrices/Arrays

Description

Function to shortcut extraction, normalization and eventually colorization of masks to matrix ! excludes image.

Usage

ExtractMasks_toMatrix(..., objects, offsets, display_progress = TRUE)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

Details

If 'param' is provided in '...', 'param$export'<-"matrix" only will be overwritten.

Value

A list of matrices/arrays of images corresponding to objects extracted.

Note

Arguments of objectExtract will be deduced from ExtractMasks_toMatrix input arguments.


FCS Keyword Checker

Description

Helper to check that FCS keyword-value pairs are compliant with specifications

Usage

FCS_check_keywords(
  text,
  delimiter,
  version = 3,
  encoding = "UTF-8",
  fun = "warning",
  ...
)

Arguments

text

a named list of keywords values.

delimiter

delimiter used to separate keyword-value pairs. /!\ NOTE that files with 0x00 'delimiter' can _NOT_ be parsed.

version

version to check keywords compliance against. Default is 3.0.

encoding

name of the encoding for raw to character conversion. Default is "UTF-8".

fun

function to execute when mandatory parameters are not met. Default is "warning". Allowed are "stop","warning","message","return".

...

other arguments to be passed.


FCS Object Data Sets Merging

Description

Merges FCS data object with various data sets.

Usage

FCS_merge_dataset(fcs, ...)

Arguments

fcs

'IFC_fcs' object as extracted by readFCS().

...

other arguments to be passed.

Details

in data can contain extra columns named 'import_file' and 'import_subfile' intended to allow file/dataset identification

Value

a list of list containing:
- header, list of header information corresponding to 'options'
- delimiter, unique character used to separate keyword-value pairs
- text, list of keywords values,
- data, data.frame of values.


FCS Object Samples Merging

Description

Merges FCS data object with various samples.

Usage

FCS_merge_sample(fcs, ...)

Arguments

fcs

'IFC_fcs' object as extracted by readFCS().

...

other arguments to be passed.

Details

in data can contain extra columns named 'import_file' and 'import_subfile' intended to allow file/dataset identification

Value

a list of list containing:
- header, list of header information corresponding to 'options'
- delimiter, unique character used to separate keyword-value pairs
- text, list of keywords values,
- data, data.frame of values.


FCS Object Converter

Description

Converts FCS data object to 'IFC_data' object.

Usage

FCS_to_data(fcs, ...)

Arguments

fcs

'IFC_fcs' object as extracted by readFCS().

...

other arguments to be passed.

Details

in data can contain extra columns named 'import_file' and 'import_subfile' intended to allow file/dataset identification

Value

A named list of class 'IFC_data', whose members are:
-description, a list of descriptive information,
-Merged_fcs, character vector of path of files used to create fcs, if input was a merged,
-Keywords, a named-list of keywords values, only keywords from 1st 'fcs' segment will be retrieved
-fileName, path of fileName input,
-fileName_image, path of .cif image fileName is referring to,
-features, a data.frame of features,
-features_def, a describing how features are defined,
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined,
-images, a data.frame describing information about images,
-offsets, an integer vector of images and masks IFDs offsets,
-stats, a data.frame describing populations count and percentage to parent and total population,
-checksum, a checksum integer.


Statistical Report Generation

Description

Generates stats report from 'IFC_data' object.

Usage

StatsReport(obj, stats)

Arguments

obj

an 'IFC_data' object.

stats

template defining stats to compute as extracted by getSTATSREPORT().

Value

a named vector with extracted statistics.


RIF/CIF File Conversion to TIFF

Description

Converts and subsets RIF or CIF files to TIFF. This function is experimental.

Usage

XIFtoTIFF(
  fileName,
  write_to,
  objects,
  offsets,
  fast = TRUE,
  endianness = .Platform$endian,
  verbose = FALSE,
  verbosity = 1,
  overwrite = FALSE,
  display_progress = TRUE,
  add_tracking = TRUE,
  ...
)

Arguments

fileName

path of file to subset. It has to be a '.rif' or '.cif' file.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'fileName'
-%p: with first parent directory of 'fileName'
-%e: with extension of 'fileName' (without leading .)
-%s: with shortname from 'fileName' (i.e. basename without extension).
Exported file extension has to be .tif or .tiff.

objects

integer vector, IDEAS objects ids numbers to use. If missing, the default, all objects will be used.

offsets

object of class ‘IFC_offset'. If missing, the default, offsets will be extracted from ’fileName'.
This param is not mandatory but it may allow to save time for repeated XIF export on same file.

fast

whether to fast extract 'objects' or not. Default is TRUE. Meaning that 'objects' will be extracted expecting that 'objects' are stored in ascending order.
Note that a warning will be sent if an 'object' is found at an unexpected order. In such a case you may need to rerun function with 'fast' = FALSE. If set to FALSE, all raw object_ids will be scanned from 'fileName' to ensure extraction of desired 'objects'.
IMPORTANT: whatever this argument is, features are extracted assuming an ascending order of storage in file.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

overwrite

whether to overwrite file or not. Default is FALSE.
Note that if TRUE, it will overwrite exported file if path of 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

display_progress

whether to display a progress bar. Default is TRUE.

add_tracking

whether to register files' paths and objects' ids in the exported file. Default is TRUE.

...

other arguments to be passed.

Details

This function is experiment and under development inputs and outputs may change in the future

Value

It invisibly returns full path of exported file.


Image Scale Bar Incrustation

Description

Adds scale bar to image

Usage

addScaleBar(
  image,
  size,
  style = c("dash", "line")[1],
  color = "white",
  res = 96,
  xoff = 0,
  yoff = 0
)

Arguments

image

a [0,1] image.

size

positive integer. Scale's bar size in micro-meter. Default is '7'.
This parameter can't be lesser than 6px and higher than image width + scale text.

style

a character string. Scale's bar style, either 'dash' or 'line'. Default is 'dash'.

color

a character string. color of the scale. Default is 'white'.

res

positive integer. Resolution in ppi of 'image'. Default is '96'.

xoff

positive integer. x offset in image to draw scale, starting from bottom left corner.

yoff

positive integer. y offset in image to draw scale, starting from bottom left corner.

Value

an image with scale added to the bottom left corner.


Image Text Incrustation

Description

Adds Text to image.

Usage

addText(image, text, color, xoff = 0, yoff = 0, corner = "TL")

Arguments

image

a [0,1] image.

text

a character string.

color

a character string. color of the text.

xoff

positive integer. x offset in image to start writing text.

yoff

positive integer. y offset in image to start writing text.

corner

a character string. where to position text in the image. Allowed are "TL", "TR", "BL", "BR", for top-left, top-right, bottom-left, bottom-right, respectively.

Details

One-lined text will be added so has to be fully contained within image and anchored at desired corner plus x and y offset from it.

Value

an image with text added.


IFC Graph Adjustment

Description

Helper to readjust 'IFC_data' graphs in case of missing feature, region, population.

Usage

adjustGraph(obj, graph, adjust_graph = TRUE, ...)

Arguments

obj

an object of class 'IFC_data' extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

graph

a graph from 'obj' or a list that can be coerced by buildGraph.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, graph(s) will be removed no matter if features, regions, pops it refers to are found in 'obj'.

...

other arguments to be passed.


Apply Gating Strategy

Description

Applies Gating Strategy to an 'IFC_data' object

Usage

applyGatingStrategy(
  obj,
  gating,
  keep,
  display_progress = TRUE,
  verbose = FALSE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

gating

an 'IFC_gating' object extracted by readGatingStrategy.

keep

names of population(s) that should not be overwritten using 'gating'.

display_progress

whether to display a progress bar. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

...

other arguments to be passed.

Details

/!\ Please note that all former gating strategy (i.e. regions, pops, graphs and stats) will be removed from returned object, with the exception of population(s) described in 'keep'.
An error will be thrown if a feature is required to create a population or a graph but can't be found in 'obj'.
When tagged population(s) is(are) imported, objects from this(these) population(s) outside 'obj' will be discarded.
If this results in NULL, then all objects will be tagged.

Value

A named list of class 'IFC_data' with new regions, pops and graphs


Apply Transformation

Description

Helper apply transformation.

Usage

applyTrans(x, trans, inverse = FALSE)

Arguments

x

a numeric vector.

trans

the object returned by parseTrans().

inverse

whether or not to apply the inverse transformation. Default is FALSE.

Details

for the moment, in addition to no transformation, only "smoothLinLog", "asinh", and "sqrt" are supported.

Value

the transformation of the input


Assert that Certain Conditions are Met

Description

Ensures that a variable respects several parameters

Usage

assert(x, len = NULL, cla = NULL, typ = NULL, alw = NULL, fun = "stop")

Arguments

x

variable to test

len

integer vector of allowed length for x. Default is NULL, for not checking this parameter.

cla

character vector of allowed classes of x. Default is NULL, for not checking this parameter.

typ

character vector of allowed types of x. Default is NULL, for not checking this parameter.

alw

allowed values for x. Default is NULL, for not checking this parameter.

fun

function to execute when mandatory parameters are not met. Default is "stop". Allowed are "stop","warning","message","return".

Details

/!\ alw parameter when used should be coercible to a logical, integer, numeric, complex or character vector. Otherwise, an error will be thrown.


Automatic Parameters Detection for IFC Graphs

Description

Function intended to generate IFC graphs with minimal inputs from users.
It is essentially based on automatic detection of graphical parameters thanks to 'shown_pops' argument.

Usage

autoplot(
  obj,
  shown_pops = NULL,
  subset = NULL,
  x = NULL,
  x_trans = NULL,
  y = NULL,
  y_trans = NULL,
  type = NULL,
  smoothingfactor = NULL,
  normalize = NULL,
  bin,
  viewport = "ideas",
  precision = c("light", "full")[1],
  color_mode = c("white", "black")[1],
  draw = TRUE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

shown_pops

one or several populations present in 'obj'. Default is NULL.
If provided, autoplot will try to display these populations. See details when not provided.

autoplot will try to determine x and y and their transformations based on 'shown_pops' parameter. If all populations provided in 'shown_pops' are siblings, region(s) from which 'shown_pops' were defined will be displayed.
In case 'shown_pops' are not siblings, they will be treated as populations and a graph will be generating with an overlay of these populations. Order of this overlay is given by order of 'shown_pops'.
Finally, changing any of the following arguments (x, x_trans, y, y_trans, type) to something else than the one detected from 'shown_pops' will prevent from displaying region(s) and 'shown_pops' populations will be displayed as overlay.
However, please consider that if original type is 'histogram' changing x_trans transformation will have no impact on this.

subset

a population present in 'obj'. Default is NULL. Background population that will be used to generate graph. This argument will not be used when graph is an histogram. If this argument is filled with a different population than what can be determined thanks to 'shown_pops', Then 'shown_pops' will be treated as overlay. However, 'shown_pops' argument can still be used to determine x, y axis and their transformation

x

feature for x-axis. Default is NULL. When empty, autoplot will try to determine if automatically from 'shown_pops' argument. If provided, x feature has to be a name from 'obj' features. Note that providing x feature : - takes precedence on automatic x-axis detection. - will reset x-axis transformation to "P" except if 'x_trans' is filled.

x_trans

parameter for x-axis transformation. Default is NULL. If not provided, transformation will be determined thanks to 'shown_pops'. It takes precedence when provided and if provided it has to be be either "P" or coercible to a positive numeric. "P" will leave x-axis as is but a positive numeric will be passed has hyper argument of smoothLinLog to transform x-axis.

y

feature for y-axis. Default is NULL. When empty, autoplot will try to determine it automatically from 'shown_pops' argument. If provided, y feature has to be a name from obj features. Note that providing y feature - takes precedence on automatic y-axis detection. - will reset y-axis transformation to "P" except if 'y_trans' is filled.

y_trans

parameter for y-axis transformation. Default is NULL. If not provided, transformation will be determined thanks to 'shown_pops'. It takes precedence when provided and and if provided it has to be be either "P" or coercible to a positive numeric. "P" will leave y-axis as is but a positive numeric will be passed has hyper argument of smoothLinLog to transform y-axis. Note that it is irrelevant for "histogram".

type

type of plot. Default is NULL to allow autoplot to detemine 'type' automatically. If provided it has to be either "histogram", "scatter", "density". Note that when "histogram" is choosen, 'subset' parameter will not be used. Note that "density" will be possible only when 'subset' will be automatically determined or filled with only one population. Note that when autoplot has determined, thanks to 'shown_pops' that original plot is an "histogram", "Object Number" will be used as y-axis by default when 'type' is forced to "scatter" or "density".

smoothingfactor

when type of graph is "histogram", whether to smooth it or not. Default is NULL. Should be an integer [0:20] Note that 0 means no smoothing and other values will produce smoothing

normalize

when type of graph is "histogram", whether to normalize it or not. Default is NULL. Should be a logical.

bin

number of bins when graph's type is "histogram" / number of equally spaced grid points for density. Default is missing to allow autoplot to determine it by itself.

viewport

Either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas".
-"ideas" will use same limits as the one defined in ideas.
-"data" will use data to define limits.
-"max" will use data and regions drawn to define limits.

precision

when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light".
-"light", the default, will only display points of same coordinates that are amoung the other layers.
-"full" will display all the layers.

color_mode

Whether to extract colors from obj in white or black mode. Default is "white".

draw

whether to draw plot. Default is TRUE.

...

Other arguments to be passed.

Details

when 'shown_pops' are not provided, autoplot can't determine anything.
So, if not provided default values will be used:
-'subset' = "All"
-'x' = "Object Number"
-'x_trans' = "P"
-'y' = "Object Number"
-'y_trans' = "P"
-'type' = "histogram"

Value

an lattice trellis object


Raw Images to Base64 Encoding

Description

Encodes raw image vector to base64 string

Usage

base64_encode(x)

Arguments

x

a raw vector.

Source

https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64


Axis Constructor

Description

Helper to rescale and label axes when linlog / asinh transformation is used.

Usage

base_axis_constr(lim, trans = "P", nint = 10)

Arguments

lim

vector of length 2 of axis extents.

trans

transformation applied. Defaut is "P".

nint

positive integer value indicating (approximately) the desired number of intervals. Default is 10.


Histogram Constructor for 'base' Plot

Description

Helper to create histogram.

Usage

base_hist_constr(
  x,
  type,
  br,
  normalize,
  fill,
  smooth,
  lwd,
  lty,
  col,
  alpha,
  border,
  include.lowest = TRUE,
  right = TRUE
)

Arguments

x

a vector of values for which the histogram is desired.

type

histogram type. Default is missing. Allowed are "count" and "percent".

br

breakpoints given an interval and the number of pieces to break it into.

normalize

whether to normalize. Default is missing.

fill

whether to fill. Default is missing.

smooth

whether to smooth. Default is missing.

lwd, lty, col, alpha, border

graphical parameters. See par() from package 'graphics'.

include.lowest

logical; if TRUE, an x[i] equal to the breaks value will be included in the first (or last, for right = FALSE) bar. This will be ignored (with a warning) unless breaks is a vector.

right

logical; if TRUE, the histogram cells are right-closed (left open) intervals.


Batch Builder

Description

Prepares XML node for ExportToBATCH.

Usage

buildBatch(
  files,
  compensation,
  analysis,
  default_batch_dir,
  config_file,
  name = "Batch1",
  use_acquisition = FALSE,
  suffix = "",
  allow_channels_dissimilarity = FALSE,
  overwrite = TRUE,
  segment_rif = "None",
  options
)

Arguments

files

path of files to batch.

compensation

path to compensation file.

analysis

path to analysis file.

default_batch_dir

directory where batches are stored.
It can be found in IDEAS(R) software, under Options -> Application Defaults -> Directories -> Default Batch Report Files Directory.
If missing, the default, it will be deduced from IDEAS(R) config file, However, if it can't be deduced then tempdir(check = TRUE) from base will be used.
This argument takes precedence over 'config_file' and filling 'default_batch_dir' prevents the use of 'config_file' argument.

config_file

path to IDEAS(R) config file.
It may depends on IDEAS(R) software installation but one may use "C:/Users/%USER%/AppData/Roaming/Amnis Corporation/userconfig.xml".

name

name of batch. Default is "Batch1".

use_acquisition

whether to use acquisition as analysis template. Default is FALSE.

suffix

suffix to add to files when batched. Default is "".

allow_channels_dissimilarity

whether to allow building batch when all files were not acquired with same channels. Default is FALSE.

overwrite

whether to overwrite files or not. Default is TRUE.

segment_rif

size of file segmentation. Default is "None", for no segmentation.
Allowed are "None", "100", "1K", "5K", "10K", "50K", "100K".

options

A list of arguments to be passed.
If missing, the default, options will be set to:
-"Brightfield compensation"=TRUE,
-"EDF deconvolution"=TRUE,
-"Camera background"=TRUE,
-"Spatial alignment"=TRUE.
Allowed are TRUE or FALSE for all, excepted for 'Spatial aligment' which can also be path to .rif file.

Value

a list containing batch information:
-xml, the xml object to be written,
-batch_dir, the directory where xml file is desired to be saved according to 'default_batch_dir' and 'config_file'.


IFC Feature Coercion

Description

Helper to build a list to allow feature export.

Usage

buildFeature(
  name,
  type = c("single", "combined", "computed")[1],
  def = "Camera Line Number",
  val = NULL,
  ...
)

Arguments

name

feature's name. If missing, it will be determined thanks to def.

type

feature's type. Default is "single". Allowed are "single", "combined", "computed".

def

definition of the feature. Default is "Camera Line Number".

val

a coercible to numeric vector of feature values. Default is NULL.
Note that although not mandatory for buildFeatureit has to be provided to allow feature export in ExportToDAF and data_add_features.

...

Other arguments to be passed.

Value

a list containing all feature information.


IFC Graph Coercion

Description

Helper to build a list to allow graph export.

Usage

buildGraph(
  type = c("histogram", "scatter", "density")[3],
  xlocation = 0,
  ylocation = 0,
  f1 = "Object Number",
  f2 = "Object Number",
  scaletype = 1,
  xmin = -1,
  xmax = 1,
  ymin = 0,
  ymax = 1,
  title = paste0(unlist(lapply(BasePop, FUN = function(x) x$name)), collapse = ", "),
  xlabel = f1,
  ylabel = f2,
  axislabelsfontsize = 10,
  axistickmarklabelsfontsize = 10,
  graphtitlefontsize = 12,
  regionlabelsfontsize = 10,
  bincount = 0,
  freq = c("T", "F")[1],
  histogramsmoothingfactor = 0,
  xlogrange = "P",
  ylogrange = "P",
  maxpoints = +Inf,
  stats = c("true", "false")[2],
  xsize = c(320, 480, 640)[1],
  ysize = xsize + ifelse(stats == "true", splitterdistance, 0),
  splitterdistance = 120,
  xstats = "Count|%Gated|Mean",
  ystats = xstats,
  order,
  xstatsorder,
  Legend,
  BasePop = list(list()),
  GraphRegion = list(list()),
  ShownPop = list(list()),
  ...
)

Arguments

type

Graph's type. Either "histogram", "scatter" or "density". Default is "density".

xlocation

Integer. Graph's x location. Default is 0.

ylocation

Integer. Graph's x location. Default is 0.

f1

Character. Graph x axis parameter. Default is "Object Number".

f2

Character. Graph y axis parameter. Default is "Object Number". Only used when 'type' is not "histogram".

scaletype

Integer. Graph scale. Either 0 (auto), 1 (manual). Default is 1.

xmin

Double. Graph's xmin. Default -1.

xmax

Double. Graph's xmax. Default 1.

ymin

Double. Graph's xmin. Default 0.

ymax

Double. Graph's xmax. Default 1.

title

Character. Graph title label. Default will use names of BasePop collapse with ', '.

xlabel

Character. Graph x axis label.

ylabel

Character. Graph y axis label.

axislabelsfontsize

Integer. Axis label font size. Default is 10. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28.
Checked but not yet implemented.

axistickmarklabelsfontsize

Integer. Axis tick font size. Default is 10. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28.
Checked but not yet implemented.

graphtitlefontsize

Integer. Axis title font size. Default is 12. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28.
Checked but not yet implemented.

regionlabelsfontsize

Integer. Axis region font size. Default is 10. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28.
Checked but not yet implemented.

bincount

Integer. Histogram bin count. Default is 0. Allowed are: 0, 8, 16, 32, 64, 128, 256, 512, 1024.

freq

Character. Histogram with frequency normalization of not. Default is "T", allowed are "T" or "F".

histogramsmoothingfactor

Integer. Histogram smoothing factor. Allowed are [0-20]. Only partly implemented, default is 0 for no smoothing other values will produce same smoothing.

xlogrange

determines transformation instruction for x-axis. Default is "P" for no transformation.

ylogrange

determines transformation instruction for y-axis. Default is "P" for no transformation.

maxpoints

determines the maximum number of points to display. Default is +Inf to display all points.
If provided, values from ]0,1] will be used as a proportion of the total number of points to show.
While values values superior to 1 will be interpreted as the maximal number of points to show.
It only applies to 2D graphs. When 'type' is "histogram", +Inf will be used whatever the value provided as input.

stats

Character. Either "true" or "false" to display stats. Default is "false".

xsize

Integer. Graph's x size. Default is 320 for small. Regular are: 320 (small), 480 (medium), 640 (big). Checked but not yet implemented.

ysize

Integer. Graph's y size. Default is 'ysize' + 'splitterdistance' when 'stats' is set to "true". Checked but not yet implemented.

splitterdistance

Integer. Default is 120. Checked but not yet implemented.

xstats

Character. x stats to be computed. Default is 'Count|%Gated|Mean'. It has to be a filled with the concatenation of 'Count', '%Total', '%Gated', '%Plotted', 'Objects/mL', 'Mean', 'Median', 'Std. Dev.', 'MAD', 'CV', 'Minimum', 'Maximum', 'Geo. Mean', 'Mode', 'Variance' and /or 'NaN', collapse with '|'. Checked but not yet implemented.

ystats

Character. y stats to be computed. Should be identical to 'xstats'. Default is xstats. Checked but not yet implemented.

order

Character. Order to display populations. When 'type' is "density" it will be BasePop[[1]]$name. When 'type' is "histogram" or "density" 'ShownPop' are not allowed Otherwise, it will use each of 'GraphRegion', 'BasePop' and 'ShownPop' names, collapse with '|'.

xstatsorder

Character. Order of stat rows. It will use each of 'GraphRegion' names & each of 'BasePop' names, reverted and collapse with '|'.

Legend

Default is list(list(onoff='false',x='0',y='0',witdh='96',height='128')). Not yet implemented.

BasePop

Default is list(list()). See details.

GraphRegion

Default is list(list()). Only allowed member are sub-list(s) with only one character component named 'name'.

ShownPop

Default is list(list()). Only allowed member are sub-list(s) with only one character component named 'name'.

...

Other arguments to be passed.

Details

Many parameters are not used or are only partly implemented, but most are checked in order to be compatible for further export.
For 'BasePop', if left as is "All" will be used as default.
This parameter will be built / checked according to 'type' argument.
'BasePop' has to be a list of list(s) and each sub-list should can contain several elements, but only "name" is mandatory.
The sublist members are:
-"name", "linestyle", "fill",
and only when 'type' is "density"
-"densitybincount", "densitymin", "densitymax",
-"densitycolors", "densitycolorslightmode", "densitycolorsdarkmode",
-"densitylevel", "densitytrans".
Each sub-list will be created automatically with the following default values (except if explicitly provided):
-linestyle="Solid",
-fill="true",
-densitybincount="128",densitymin="0",densitymax="0",
-densitycolors="-16776961|-13447886|-256|-23296|-65536|",
-densitycolorslightmode="-16776961|-13447886|-256|-23296|-65536|",
-densitycolorsdarkmode="-16776961|-13447886|-256|-23296|-65536|",
-densitylevel="",
*when provided it has to be in a format of "fill[true,false]|lines[true,false]|nlevels[integer>1]|lowest[numeric[0-1[]|" *describing how the levelplot should be drawn.
*Besides, 'densitrans' will not be used. -densitytrans="asinh"
*it can take a function to be applied to the 2D local densities
*or a name of a feature within 'IFC_data' object to draw a gradient against this feature
Note that when 'type' is "density", 'BasePop' should be of length one.
and fill will be overwritten to "true".

Value

a list containing all graph information.


Image Field Directory Builder

Description

Builds Image Field Directory (IFD)

Usage

buildIFD(val, typ, tag, endianness = .Platform$endian)

Arguments

val

the value of the IFD

typ

desired IFD type

tag

the desired IFD 'tag'

endianness

the desired endian-ness ("big" or "little"). Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

Details

if 'val' if of type "character", 'tag' is automatically set to 2.
if 'val' is of length 0 NULL is returned.

Value

NULL or a list of 2 members:
-min_content: the minimal IFD content,
-add_content: the additional IFD content if 'val' converted to raw does not fit in 4 bytes.


IFC Image Coercion

Description

Helper to build a list image values to allow export

Usage

buildImage(physicalChannel = 1, ..., BF = FALSE, MODE = 1)

Arguments

physicalChannel

the channel. Default is 1. Allowed are [1-12].

...

other arguments to be passed. See members in returned value.

BF

should 'physicalChannel' channel be considered as brightfield. Default is FALSE.

MODE

collection mode (as retrieved by getInfo) determining the range. Default is 1.

Value

a list whose members are "name", "color", "physicalChannel", "xmin", "xmax", "xmid", "ymid", "scalemin", "scalemax", "tokens", "baseimage", "function", "saturation".


IFC Mask Coercion

Description

Helper to build a mask.

Usage

buildMask(
  masks,
  images,
  definition = TRUE,
  to_match_mask = NULL,
  to_replace_mask = NULL,
  to_match_image = NULL,
  to_replace_image = NULL,
  ...
)

Arguments

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

definition

whether to compute masks definition or masks names. Default is TRUE, to compute definition.

to_match_mask

a vector of masks names to use for matching 'masks' names. Default is NULL

to_replace_mask

a vector of masks names to use for replacing 'masks' names. Default is NULL

to_match_image

a vector of images names to use for matching 'images' names. Default is NULL

to_replace_image

a vector of images names to use for replacing 'images' names. Default is NULL

...

Other arguments to be passed.

Details

function that can either change definition or name it will be used in a loop to incorporate new definition. causing name to be changed. allowing new redefinition of mask dependent on other mask to be changed, and so on when a mask or an image name is not found because not yet defined an error is raised and catched TODO maybe this error catching causes some overhead to be improved

Value

a vector of masks definition or names depending on 'definition' parameter.


IFC Population Coercion

Description

Helper to build a list to allow population export.

Usage

buildPopulation(
  name,
  type,
  base = "All",
  color,
  lightModeColor,
  style,
  region,
  fx,
  fy,
  definition,
  obj,
  ...
)

Arguments

name

name of the population.

type

type of population. Either "B", "C", "G" or "T" for Base, Combined, Graphical or Tagged, respectively.
If missing, the default, 'type' will be deduced from other parameters. If 'name' is "All" type will be "B". Otherwise, if 'fx' is given type will be "G". Otherwise, "T", if 'definition' is missing but not 'obj' or "C" if 'definition' is not missing.

base

which population is based on. It will be base="All", for 'type' "T" and "C" and base="", for 'type' "B". It is only needed when type = "G".

color

color of the population. See paletteIFC for allowed colors. If not provided, it will be sampled.

lightModeColor

lightModeColor of the population. See paletteIFC for allowed colors. If not provided, it will be sampled.

style

style of the population. Either 20, 4, 3, 1, 5, 0, 2, 18, 15, 17, respectively for: "Simple Dot", "Cross", "Plus", "Empty Circle", "Empty Diamond", "Empty Square", "Empty Triangle", "Solid Diamond", "Solid Square", "Solid Triangle".

region

Only if type="G". Name of the region defining the population.

fx

Only needed if type="G". Name of the x-feature defining the population.

fy

Only needed if type="G" and only if region is defined in 2D. Name of the y-feature defining the population.

definition

Only needed if type="C". Parameters defining the population.

obj

Only needed if type="T". Either a:
-Logical vector of same length as "All" population indicating if a cell belongs to the population or not.
-Integer vector of indices of cells that belongs to the population. Note that first object is 0.

...

Other arguments to be passed.

Value

a list containing all population information.


IFC Region Coercion

Description

Helper to build a list to allow region export.

Usage

buildRegion(
  type,
  label,
  cx,
  cy,
  color,
  lightcolor,
  ismarker = "false",
  doesnotoverride = "false",
  xlogrange,
  ylogrange,
  x,
  y,
  ...
)

Arguments

type

Region's type. Either "line", "rect", "poly" or "oval".

label

label of the region.

cx

x label's position. If not provided x center will be used.

cy

y label's position. If not provided y center will be used.

color

color of the region. See paletteIFC for allowed colors.

lightcolor

lightcolor of the region. See paletteIFC for allowed colors.

ismarker

Default is 'false'. Allowed are 'true' or 'false'. Used for compatibility with amnis file but role remains unknown.

doesnotoverride

Default is 'false'. Allowed are 'true' or 'false'. Used for compatibility with amnis file but role remains unknown.

xlogrange

determines transformation instruction for x-axis. Default is "P" for no transformation.

ylogrange

determines transformation instruction for y-axis. Default is "P" for no transformation.

x

vector of x vertices values.

y

vector of y vertices values.

...

Other arguments to be passed.

Value

a list containing all region information.


IFC Statistics Coercion

Description

Helper to build a list to allow statistics export.

Usage

buildStats(
  obj,
  stats = list(list(type = "COUNT", title = "Count", def = ""), list(type =
    "PERCENT_GATED", title = "%Gated", def = "")),
  width = 80 * (1 + length(stats)),
  height = 240,
  xlocation = 0,
  ylocation = 0,
  ...
)

Arguments

obj

an 'IFC_data' object

stats

list of statistics instructions, whose members are list containing 3 instructions:
- 'type' stats's type. Allowed are "COUNT","PERCENT_GATED","CONCENTRATION","PERCENT","MEAN","MEDIAN","STDDEV","MAD","CV","MINIMUM","MAXIMUM","GEOMETRIC_MEAN","MODE","VARIANCE","NAN","MEAN_RD","MEDIAN_RD".
- 'title' stats's title. If missing, it will be determined thanks to def.
- 'def' definition of the stats.
Default is:
list(list(type="COUNT",title="Count",def=""),
list(type="PERCENT_GATED",title="%Gated",def=""))

width

desired width. Default is 80 * (1 + length(stats)).

height

desired height Default is 400.

xlocation

x location in analysis workspace. Default is 0.

ylocation

y location in analysis workspace. Default is 0.

...

Other arguments to be passed.

Details

when stats$type is:
- "COUNT","PERCENT_GATED","CONCENTRATION", stats$def will be "",
- "PERCENT", stats$def has to be a population name,
- "MEAN_RD","MEDIAN_RD" stats$def has to be the concatenation of a feature name and a population name collapse with "|". e.g. "Area_MC|All",
- otherwise, stats$def has to be a feature name.

Value

an object of class 'IFC_stats'.


2D Binned Kernel Density Estimation

Description

Helper to compute density plot

Usage

calcDensity(x, nbin, bandwidth, range.x)

Character Color Check and RGB Conversion

Description

Checks that color is R compatible by converting it to RGB matrix.

Usage

checkColor(color)

Arguments

color

a character string.


'IFC_data' Object Check

Description

Ensures 'IFC_data' obj$features correctly reflects actual number of collected objects. When 'obj' is from rif or cif, number of objects can be different from actual number of collected objects e.g. when it comes from merged of subset of file. There is no way to link an object with its feature value, so the only solution is to remove all features and only keep "Object Number".

Usage

checkObj(obj)

Arguments

obj

an 'IFC_data' object.

Value

an 'IFC_data' object.


DAF File Checksum

Description

This function returns CIF checksum computed from images values found in DAF Checksum is the sum of img IFDs (Image Field Directory) offsets of objects 0, 1, 2, 3 and 4.

Usage

checksumDAF(fileName, endianness = .Platform$endian, ...)

Arguments

fileName

path to file.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

...

other arguments to be passed.


IFC Files Checksum

Description

This function returns RIF/CIF checksum. Checksum is the sum of img IFDs (Image Field Directory) offsets of objects 0, 1, 2, 3 and 4.

Usage

checksumIFC(fileName, ...)

Arguments

fileName

path to file.

...

arguments to pass to checksumDAF or checksumXIF.

Details

if fileName is a DAF file, then CIF checksum is computed from images values found in DAF.

Value

an integer corresponding to IFC file checksum.


RIF/CIF File Checksum

Description

This function returns RIF/CIF checksum. Checksum is the sum of img IFDs (Image Field Directory) offsets of objects 0, 1, 2, 3 and 4.

Usage

checksumXIF(fileName, ...)

Arguments

fileName

path to file.

...

other arguments to be passed.


Integer to Hexadecimal Color Conversion

Description

Helper to convert color to hex

Usage

colConv(col)

Raw Vectors Collapse

Description

Collapses raw vectors together

Usage

collapse_raw(x, collapse = as.raw(124))

Arguments

x

a list of raw vectors.

collapse

a raw vector used to collapse. Default is as.raw(0x7c)

Value

a collapsed raw vector


Image Gamma Computation

Description

Computes image gamma transformation value.

Usage

computeGamma(V)

Arguments

V

channel display properties containing 'xmin', 'xmax', 'xmid' and 'ymid'.

Details

Thanks to http://www.libpng.org/pub/png/book/chapter10.html image_sample = light_out ^ gamma it is said that Once again, bear in mind that light_out and image_sample are scaled to the interval between 0 and 1; that is, if the sample depth is 8 bits, the file samples range between 0 and 255, so image_sample is obtained by dividing a given file sample by 255, in floating-point arithmetic. So, image_sample = ymid and its range is [0,255] light_out = xmid and its range is [xmin,xmax] we have ymid / 255 = ((xmid - xmin) / (xmax - xmin)) ^ gamma log(ymid / 255) = log((xmid - xmin) / (xmax - xmin)) * gamma gamma = log(ymid / 255) / log((xmid - xmin) / (xmax - xmin))


Spillover Converter

Description

Converts spillover matrix to spillover keyword and reversely

Usage

convert_spillover(spillover)

Arguments

spillover

either a spillover matrix or a spillover keyword

Value

if 'spillover' is a matrix, it returns a string. If 'spillover' is a string, it returns a matrix. In all cases if spillover is of length 0, it will return NULL.


User's Coordinates to Pixels Conversion

Description

Helper map user's coordinates to pixels

Usage

coord_to_px(coord, coordmap, pntsonedge = FALSE)

Arguments

coord

coordinates in user system. A matrix where rows are points and with at least 2 columns named "x" and "y" for x and y coordinates, respectively.

coordmap

current device adjusted coordinates. Default is missing.

pntsonedge

whether points outside of plotting region should be bounded on the edge. Default is FALSE to clip points.

Value

a 2-columns matrix with "x" and "y" coordinates.


Matrix HSV to RGB Conversion

Description

Converts grayscale [0,1] mat to 3D rgb array according to hsv space. hue and saturation determines tint whereas v is given by each element of mat

Arguments

mat

NumericMatrix, [0,1].

h

double, [0,1], hue. Default is 0.0

s

double, [0,1], saturation. Default is 0.0

Value

a NumericVector with 3 dimensions attribute i.e. a 3D array - 1st Dim is matrix rows count, - 2nd Dim is matrix cols count, - 3rd Dim is RGB


Spatial Offsets Image Correction

Description

This function uses bilinear interpolation to apply spatial offset correction on image

Arguments

mat

a NumericMatrix.

dx

a double x spatial offset. It has to be within ]-1,+1[. Default is NA_REAL for no change.

dy

a double y spatial offset. It has to be within ]-1,+1[. Default is NA_REAL for no change.

Details

It is intended to be applied on raw images matrices from .rif files so has to generate spatial offset corrected image matrices.
See William E. Ortyn et al. Sensitivity Measurement and Compensation in Spectral Imaging. Cytometry A 69 852-862 (2006). doi: 10.1002/cyto.a.20306

Value

a NumericMatrix.


Image to Native Raster Conversion

Description

Converts 3D image array to nativeRaster

Arguments

x

an IntegerVecter /!\ It should be coercible to 3D array [height, width, rgba]

Value

a nativeRaster IntegerMatrix


Input Parameters Assertive Tool

Description

Ensures that x respects several parameters

Arguments

len

IntegerVector, of allowed length for x. Default is NULL, for not checking this parameter.

cla

CharacterVector, of allowed classes of x. Default is NULL, for not checking this parameter.

typ

CharacterVector, of allowed types of x. Default is NULL, for not checking this parameter.

Robject

of allowed values for x (will be passed to cpp_allowed). Default is NULL, for not checking this parameter.

fun

CharacterVector, function to execute when mandatory parameters are not met. Default is "stop". Allowed are "stop","warning","message","return". fun is placed in cpp_assert() in order to check it is correct before being used in assert() function.


Raw to Base64 Conversion

Description

Converts a raw vector to base64 string.

Arguments

x

RawVector.

Value

a string, representing the base64 encoding of x.


TIFF Checker

Description

Checks if file is a TIFF.

Arguments

fname

string, path to file.

Details

If file is a TIFF it returns endianness of file, 'big' or 'little. Otherwise, it shows an error and returns an empty string.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


Checksum for RIF/CIF

Description

Computes sum of img IFDs (Image Field Directory) offsets of objects 0, 1, 2, 3 and 4.

Arguments

fname

string, path to file.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


Matrix Cleanser

Description

Replaces values in matrix mat according to mask msk. Depending of 'add_noise' parameter, values of 'mat' will be replaced with noise or not.

Arguments

mat

a NumericMatrix.

msk

a IntegerMatrix.

add_noise

bool, whether to add normal noise or not, Rcpp::Rf_rnorm(bg, sd) function is used. Default is true.

bg

double, mean value of the background added if 'add_noise' is true. Default is 0.0.

sd

double, standard deviation of the background added if 'add_noise' is true. Default is 0.0.

Value

a NumericMatrix cleansed according to 'msk'.


Gamma Computation

Description

This function computes image gamma transformation value.

Arguments

V

named NumericVector of channel display properties containing 'xmin', 'xmax', 'xmid' and 'ymid'.


Coordinates to Pixels

Description

low-level function to compute pixels coordinates

Arguments

x

NumericVector of x-coordinates of the points.

y

NumericVector of y-coordinates of the points.

param

NumericVector of parameters to scale raw points coordinates to pixels coordinates.

Value

a 2 columns NumericMatrix of x and y pixels coordinates.


Matrix Cropping

Description

Crops mat according to new_height and new_width parameters.

Arguments

mat

a numeric matrix.

new_height

an unsigned integer, giving the new height of returned mat. Default is 0 for no change.

new_width

an unsigned integer, giving the new width of returned mat. Default is 0 for no change.

Value

a cropped matrix.


IFC_object Decompression

Description

Operates decompression of compressed image stored in TIFF file.

Arguments

fname

string, path to file.

offset

std::size_t, position of the beginning of compressed image.

nbytes

uint32_t, number of bytes of compressed image.

imgWidth

R_len_t, Width of the decompressed image. Default is 1.

imgHeight

R_len_t, Height of the decompressed image. Default is 1.

nb_channels

R_len_t, number of channels of the decompressed image. Default is 1.

removal

uint8_t, object removal method. Only apply for 30818 compression. Default is 0.
-1, for clipped removal: height OR width clipped pixels will be set to -1.
-2, height clipped removal: height clipped pixels will be set to -1.
-3, width clipped removal: width clipped pixels will be set to -1.
-4, only keep background: background pixels will be set to 1 and all others to 0.
-5, only keep foreground: foreground pixels will be set to 1 and all others to 0.

compression

uint32_t, compression algorithm used. Default is 30818.

verbose

bool, whether to display information (use for debugging purpose). Default is false.

Source

For image decompression, Lee Kamentsky's code porting from https://github.com/ome/bioformats/blob/4146b9a1797501f0fec7d6cfe69124959bff96ee/components/formats-bsd/src/loci/formats/in/FlowSightReader.java
cited in https://linkinghub.elsevier.com/retrieve/pii/S1046-2023(16)30291-2
⁠ BSD implementations of Bio-Formats readers and writers Copyright (C) 2005 - 2017 Open Microscopy Environment: - Board of Regents of the University of Wisconsin-Madison - Glencoe Software, Inc. - University of Dundee Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ⁠


Draw Shape to Image

Description

low-level function to add shape on image

Arguments

img

an IntegerVector. A non null array of dimensions [nrow, ncol, 4].

coords

an IntegerMatrix whose rows are points to draw and with:
- 1st column being img col coordinate in px,
- 2nd column being img row coordinate in px.

mask

a LogicalMatrix where every true value will be added to the image.

color

a 4 rows IntegerMatrix specifying rgba, from 0 to 255.

blur_size

a R_len_t the size of the gaussian blurring kernel. Default is 9.

blur_sd

a double the sd of the gaussian blurring kernel. Default is 3.0.

Details

shape according to 'mask' will be drawn on 'img' centered at coordinates coords[, 1], coords[, 0] and every pixels being part of the shape will be filled with 'color'. If only one 'color' is provided, this 'color' will be used for each points. If more than one 'color' is provided, then if number of colors (ncol) equals the number of points 'color' will be used as is for each single point. Otherwise, 'color' will be considered as a color-gradient and density will be computed. /!\ please note that IFC:::densCols() is faster to compute color based on density for n < 20000 points, so it's worth using it when number of points are lower.

Value

/!\ nothing is returned but img is modified in-place


Ellipse Boundaries to Coordinates

Description

Transforms ellipse boundaries to usefull coordinates.

Arguments

bound_x

NumericVector, x-boundaries of the ellipse.

bound_y

NumericVector, y-boundaries of the ellipse.


IFC_object Extraction

Description

Extracts object from ifd

Arguments

fname

string, path to file

ifd

List, ifd information of class IFC_ifd

colors

List of colors to use.

channels

DataFrame, channels information.

physicalChannel

CharacterVector of indices for each channel.

xmin

NumericVector of minimal values for each channel.

xmax

NumericVector of maximal values for each channel.

spatialX

NumericVector of X spatial offset correction for each channel.

spatialY

NumericVector of Y spatial offset correction for each channel.

removal

IntegerVector of removal method to be used for each channel.

add_noise

LogicalVector of whether to 'add_noise' for each channel.

full_range

LogicalVector of whether to use 'full_range' for each channel.

force_range

LogicalVector of whether to use 'force_range' for each channel.

gamma

NumericVector of the 'gamma' for each channel.

chan_to_extract

IntegerVector, channels to extract.

extract_msk

uint8_t, type of mask to extract:
-0: no mask,
-1: at least one "raw",
-2: at least one "clipped",
-3: at least one "masked",
-4: at least one "MC" mask.

mode

string, color mode export. Either "rgb", "gray" or "raw". Default is "raw".

size

a length 2 IntegerVector of final dimensions (height,width) of the image. Default is 0,0 for no change.

verbose

bool, whether to display information (use for debugging purpose). Default is false.

Details

When 'add_noise' is false, background will be automatically set to minimal pixel value for "masked" and "MC" 'removal' method.


IFD Fast Tags Extraction

Description

Returns TAGS contained within an IFD (Image Field Directory) entry.

Arguments

fname

string, path to file.

offset

std::size_t, position of the IFD beginning.

swap

bool, whether to swap bytes or not. Default is 'false'.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


Fast Factorize Vector

Description

Makes factor with Rcpp

Arguments

x

a SEXP only NILSXP, LGLSXP, INTSXP, REALSXP, STRSXP, RAWSXP are handled.

handleNA

a bool specifying if NA should be returned as NA or if they should be attributed a unique integer.

Details

returned object should not be of class ‘factor' so has to prevent malformed factor’ error when printing the result in R. For this reason, it is aimed to be wrap in an R function to handle factor class / handleNA balance.
e.g. either: - structure(cpp_fast_factor(df, TRUE), class = "factor"), or, - structure(cpp_fast_factor(unclass(df), FALSE), levels = NULL)

Value

an IntegerVector, with attributes "levels" being the non-NA unique value(s) found and "lvs" the total number of unique values found (including NA).

Source

adaptation from Kevin Ushey code https://gallery.rcpp.org/articles/fast-factor-generation/


Use Rcpp to Apply Any on List members

Description

Computes any across list members

Arguments

L_

a Nullable List.

Value

a LogicalVector.


Use Rcpp for Range

Description

Determines range of numeric vector

Arguments

x_

a Nullable NumericVector.

Details

the behaviour is the same as R base::range(x_, na.rm = TRUE, finite = TRUE) without creating warnings

Value

a NumericVector.


Use Rcpp to Apply Any on Matrix Rows

Description

Computes any across matrix rows.

Arguments

M_

a Nullable LogicalVector. /!\ But cast to LogicalMatrix

Value

a LogicalVector.


Use Rcpp for Sampling

Description

Create a sample of integers

Arguments

n

a R_len_t, max number integers to choose from.

size

a R_len_t the desired size of return integers.

replace

a bool determining if sampling should be done with replacement. Default is false.


Get Current Compilation Bits Depth

Description

Retrieve size of std::size_t.

Value

an unsigned integer


IFD Tags Extraction

Description

Returns TAGS contained within an IFD (Image Field Directory) entry.

Arguments

fname

string, path to file.

offset

std::size_t, position of the IFD beginning.

verbose

bool, whether to display information (use for debugging purpose). Default is 'false'.

trunc_bytes

uint32_t maximal number of individual scalar to extract BYTE/ASCII/SBYTE/UNDEFINED for TAGS (1, 2, 6 or 7). Default is 12.
However, if less is found, less is returned in map. Note that, if 0 is provided, it will be automatically set to 1.

force_trunc

whether to force truncation for all TAGS types. Default is FALSE.
If 'true', 'trunc_bytes' will be used for TAGS (3, 4, 5, 8, 9, 10, 11 and 12) to extract desired number of individual scalar corresponding to each types.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


Get Bytes Order

Description

This function expands bytes order to the whole data

Arguments

obj

number of objects in the data.

byt_

IntegerVector of number of bytes to take from 'ord_'.

ord_

IntegerVector bytes order.

rev

bool whether to reverse order or not. Default is false.


IFC_offsets Computation without Id Determination

Description

Returns offsets of the IFDs (Image Field Directory) within a TIFF file.

Arguments

fname

string, path to file.

obj_count

R_len_t, numbers of objects present in the file. Default is 0. If obj_count <= 0 then progress_bar is forced to false.

display_progress

bool, whether to display a progress bar. Default is false.

pb

a List of class 'IFC_progress' containing a progress bar of class 'txtProgressBar', 'winProgressBar' or 'Progress'. Default is R_Nilvalue.

verbose

bool, whether to display information (use for debugging purpose). Default is false.

Value

an numeric vector with offsets of IFDs found.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


IFC_offsets Computation with Object Identification

Description

Returns offsets of the IFD (Image Field Directory) within a TIFF file.

Arguments

fname

string, path to file.

obj_count

R_len_t, numbers of objects present in the file. Default is 0. If obj_count <= 0 then progress_bar is forced to false.

display_progress

bool, whether to display a progress bar. Default is false.

pb

a List of class 'IFC_progress' containing a progress bar of class 'txtProgressBar', 'winProgressBar' or 'Progress'. Default is R_Nilvalue.

verbose

bool, whether to display information (use for debugging purpose). Default is false.

Value

a list of numeric vectors with OBJECT_ID, TYPE and OFFSET of IFDs found.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


Data Frame Merge Groups with Rcpp

Description

Computes global grouping factor from data.frame columns

Arguments

df

a DataFrame.

Value

an IntegerVector with the resulting global grouping factor and a "table" attribute representing the amount of scalar in each resulting level.


Int32 to Uint32 32bits Conversion

Description

Converts 32bits integer from signed to unsigned

Arguments

x

int32_t.


Int64 to Uint64 64bits Conversion

Description

Converts 64bits integer from signed to unsigned

Arguments

x

int64_t.


Inverse Smooth LinLog Transformation with Rcpp

Description

Takes a numeric vector and return its transformation: - to linear, if abs(x) < log(base) / lin_comp. - to exp, if abs(x) > log(base) / lin_comp.

Arguments

x

NumericVector.

hyper

double, value where transition between Lin/Log is applied.

base

double, base of Log scale.

lin_comp

double, value that is used to smooth transition between Lin/Log.


Matrix to Matrix Writer According to Mask with Offsets

Description

Writes matrix 'B' in matrix 'A' according to 'mask'.

Arguments

A

a NumericMatrix.

B

a NumericMatrix.

mask

a NumericMatrix.

xoff

x offset in 'A' to start writing 'B'.

yoff

x offset in 'A' to start writing 'B'.

invert

a logical. Default is false. When false, the default, values of 'B' are written into 'A' when 'mask' is not 0.0. When true, values of '1-B' are written into 'A' when 'mask' is not 0.0.


Equal Sized Matrix to Matrix Writer According to Mask

Description

Writes matrix 'B' in matrix 'A' according to 'mask'. If 'mask' is not 0.0 'B' is written, 'A' otherwise.

Arguments

A

a NumericMatrix.

B

a NumericMatrix.

mask

a NumericMatrix.


Multiple Pattern Fixed Matching

Description

String matching with multiple pattern.

Arguments

x, pattern

Nullable Rcpp CharacterVector.

Details

equivalent of as.logical(sum(unlist(lapply(pattern, grepl, x = x, fixed = TRUE)))).

Value

a bool


Matrix Normalization

Description

Normalizes a finite matrix to [0,1]

Arguments

mat

a finite NumericMatrix.

input_range

a finite NumericVector, sets the range of the input intensity values. Values outside this range are clipped. Default is [0.0,4095.0].

full_range

if 'full_range' is true, then 'input_range' will be set to [0.0,4095.0] and 'gamma' forced to 1.0. Default is false.

force_range

if 'force_range' is true, then 'input_range' will be adjusted to 'mat' range in [-4095.0, +inf] and 'gamma' forced to 1.0. Default is false.
Note that this parameter takes the precedence over 'input_range' and 'full_range'.

gamma

correction. Default is 1.0, for no correction.


Offset to Raw Conversion

Description

Converts offset to raw

Arguments

x

double.

swap

bool, whether to swap or not.


Point in Gate

Description

This function checks if points lie in a polygon or ellipse.

Arguments

pnts

NumericMatrix, a 2-columns matrix with (x and y) coordinates of the points of interest.

gate

NumericMatrix, a 2-columns matrix defining polygon vertices or ellipse boundaries.

algorithm

int, used for computation. Default is 1.
1: Trigonometry.
2: Special case = axes-aligned rectangle.
3: Special case = axes-aligned ellipse.

epsilon

double, epsilon threshold value. Default is 0.000000000001


Raster Image

Description

low-level function to create plot raster

Arguments

width

a uint16_t determining the returned image width.

height

a uint16_t determining the returned image height.

obj

a List containing drawing information:
- pch, an integer specifying a symbol to draw. Handled are [0-20]. Otherwise only a pixel will be drawn.
- size, an integer specifying the size in pixel of the shape, from 1 to 255.
- color a 4 rows IntegerMatrix (rgba) of the color used to draw the shape.
- coords, an IntegerMatrix whose rows are points to draw and with:
-* 1st column being img col coordinate in px,
-* 2nd column being img row coordinate in px. - blur_size an integer controlling the size of the blurring gaussian kernel.
- blur_sd a double controlling the sd of the blurring gaussian kernel.

bg_

a Nullable IntegerVector that will be cast to 3D array when not NULL. Default is R_NilValue.
When not NULL, its dimensions should be the same as required by 'width' and 'height', otherwise an error will be thrown.
When not NULL, it will serve as a background to draw new points on top of it.

Details

shape according to 'pch' will be drawn centered at coordinates obj$coord[, 1], obj$coord[, 0] and every pixels being part of the shape will be filled with 'color'. If only one 'color' is provided, this 'color' will be used for each points. If more than one 'color' is provided, then if number of colors (ncol) equals the number of points 'color' will be used as is for each single point. Otherwise, 'color' will be considered as a color-gradient and density will be computed. /!\ please note that IFC:::densCols() is faster to compute color based on density for n < 20000 points, so it's worth using it when number of points are lower.

Value

an IntegerVector with dimensions [height, width, 4]


Offset to Raw Conversion

Description

Converts raw to offset

Arguments

x

RawVector.

swap

bool, whether to swap or not.


IFC_object Decompression to RAW

Description

Operates decompression to raw of compressed image stored in TIFF file.

Arguments

fname

string, path to file.

offset

std::size_t, position of the beginning of compressed image.

nbytes

uint32_t, number of bytes of compressed image.

imgWidth

uint32_t, Width of the decompressed image. Default is 1.

imgHeight

uint32_t, Height of the decompressed image. Default is 1.

compression

uint32_t, compression algorithm used. Default is 30818.

swap

bool, whether to swap bytes or not. Default is false.

verbose

bool, whether to display information (use for debugging purpose). Default is false.

Source

For image decompression, Lee Kamentsky's code porting from https://github.com/ome/bioformats/blob/4146b9a1797501f0fec7d6cfe69124959bff96ee/components/formats-bsd/src/loci/formats/in/FlowSightReader.java
cited in https://linkinghub.elsevier.com/retrieve/pii/S1046-2023(16)30291-2
⁠ BSD implementations of Bio-Formats readers and writers Copyright (C) 2005 - 2017 Open Microscopy Environment: - Board of Regents of the University of Wisconsin-Madison - Glencoe Software, Inc. - University of Dundee Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ⁠


Non Finite Values Replacement

Description

This function replaces non finite values (NA, NaN -Inf and +Inf)

Arguments

V_

a NumericVector.

by

a double used as replcaement value. Default is 0.0


Matrix Resizing

Description

Resizes mat according to new_height and new_width parameters.

Arguments

mat

a numeric matrix.

new_height

an unsigned integer, giving the new height of returned mat. Default is 0 for no change.

new_width

an unsigned integer, giving the new width of returned mat. Default is 0 for no change.

add_noise

logical, if true adds normal noise when at least one new dimension is larger than original mat dimensions Rcpp::rnorm() function is used. Default is true.

bg

double, mean value of the background added if add_noise is true. Default is 0.

sd

double, standard deviation of the background added if add_noise is true. Default is 0.

Value

a resized matrix with padding background if new_height or new_width is larger than original mat dimensions.


File Scanner

Description

Scans file for 1st occurence of a target string. If found, it returns the position in bytes of the target. Otherwise, it returns 0.

Arguments

fname

string, path to file.

raw

a Rcpp::RawVector, exact target to be searched for. When converted to string it should be of at least 1 character and not exceed 1024 characters.

start

size_t, position where to begin search. It can't be superior or equal than file size or end (when end is different from 0 and inferior than file size).

end

size_t, position where to stop searching. Default is 0. Search will end up at this position unless it is higher than file size. In such case, search will end up when file end will be reached.

buf_size

uint8_t, size of buffer used to search for target (in kilo-Bytes, will be forced to be between 2 and 1024). Default is 64.

Value

size_t index of first target character found within target plus 1 or 0 if not found.


Sequence of Strings Matching

Description

Match a sequence of strings in another string

Arguments

x, y

StringVector to match

Details

smallest sequence will be searched into the largest one.

Value

the index (starting at 1) when a match has been found. Otherwise 0.


Smooth LinLog Transformation with Rcpp

Description

Takes a numeric vector and return its transformation: - to linear, if abs(x) < hyper. - to log, if abs(x) > hyper.

Arguments

x

NumericVector.

hyper

double, value where transition between Lin/Log is applied.

base

double, base of Log scale.

lin_comp

double, value that is used to smooth transition between Lin/Log.


Matrix Transformation

Description

Function to normalize, colorize and add background to images.

Arguments

mat

NumericMatrix.

color

NumericVector, whose members are h,s,v color. This vector has to be named with 1st name being the name of this color.

msk

IntegerMatrix.

size

a length 2 IntegerVector, of final dimensions (height,width) of the image. Default is 0,0 for no change.

mode

string, color mode export. Either "rgb", "gray" or "raw". Default is "raw".

type

uint16_t image object type. Default is 2.

input_range

a finite NumericVector, only apply when 'mode' is not "raw", sets the range of the input intensity values. Values outside this range are clipped. Default is [0.0,4095.0].

add_noise

bool, whether to add normal noise or not. Default is true.

bg

double, mean value of the background added if 'add_noise' is true. Default is 0.0.

sd

double, standard deviation of the background added if 'add_noise' is true. Default is 0.0.

full_range

bool, only apply when 'mode' is not "raw", if 'full_range' is true, then 'input_range' will be set to [0.0,4095.0] and 'gamma' forced to 1.0. Default is false.

force_range

bool, only apply when 'mode' is not "raw", if 'force_range' is true, then 'input_range' will be adjusted to object range in [-4095.0, +inf] and 'gamma' forced to 1.0. Default is false.
Note that this parameter takes the precedence over 'input_range' and 'full_range'.

gamma

correction. Default is 1.0, for no correction.

spatialX

X offset correction. Default is 0.0 for no change.

spatialY

Y offset correction. Default is 0.0 for no change.

Details

When a mask is detected, 'add_noise', 'full_range' and 'force_range' are set to false, 'bg' and 'sd' to 0.0, 'input_range' to [0.0,3.0] and 'gamma' to 1.0.

Experimental (as of v0.2.0.501): when 'mode' is not "raw", if 'input_range' is within ]0,1[, it will be used as 'probs' argument to quantile to determine clipping range from image object, in addition, 'gamma' will be forced to 1.0.


Uint32 to Int32 32bits Conversion

Description

Converts 32bits integer from unsigned to signed

Arguments

x

uint32_t.


Uint32 to Raw Conversion

Description

Converts unsigned 32bits integer to raw

Arguments

x

uint32_t.


Uint64 to Int64 64bits Conversion

Description

Converts 64bits integer from unsigned to signed

Arguments

x

uint64_t.


Vectorize Int32 to Uint32 32bits Conversion

Description

Converts 32bits vector of integers from unsigned to signed

Arguments

V

a NumericVector


Vectorize Int64 to Uint64 64bits Conversion

Description

Converts 64bits vector of integers from unsigned to signed

Arguments

V

a NumericVector


BMP Writer

Description

Transforms 3D [0,1] image to uncompressed bmp

Arguments

image

a [0,1] normalized image matrix or 3D array. If 3D array, 3rd dimension should be of length 1 or 3.


Add Feature to IFC_data Object

Description

Adds features to an already existing 'IFC_data' object.

Usage

data_add_features(obj, features, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

features

a list of features to add to obj. Each element of this list will be coerced by buildFeature.

...

Other arguments to be passed.

Details

A warning will be thrown if a provided feature is already existing in obj.
In such a case this feature will not be added to obj.
If any input feature is not well defined and can't be created then an error will occur.

Value

an IFC_data object with features added.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  ## copy 1st feature found in daf
  feat_def <- daf$features_def[[1]]
  if(length(feat_def) != 0) {
    feat_def_copy <- feat_def
    ## modify name and value of copied features
    feat_def_copy$name <- "copied_feature"
    feat <- daf$features[, feat_def$name]
    feat_copy <- feat
    feat_copy <- feat_copy * 10
    ## create new object with this new feature
    dafnew <- data_add_features(obj = daf, features = list(c(feat_def_copy, list(val = feat_copy))))
  }
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Add Graphs to IFC_data Object

Description

Adds graphs to an already existing 'IFC_data' object.

Usage

data_add_graphs(obj, graphs, adjust_graph = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

graphs

a list of graph(s) to add to obj. Each element of this list will be coerced by buildGraph.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, is not allowed and will throw an error.

...

Other arguments to be passed.

Value

an IFC_data object with graphs added.


Population Sampling

Description

Creates a sample from a population

Usage

data_add_pop_sample(obj, pop, size, new_name, random_seed = NULL, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

pop

name of the population to sample.

size

a non-negative integer giving the number of items to choose.

new_name

name of the exported population.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

...

Other arguments to be passed.

Details

population is exported as tagged population.

Value

an IFC_data object with sampled pop added.


Add Population to IFC_data Object

Description

Adds populations to an already existing 'IFC_data' object.

Usage

data_add_pops(
  obj,
  pops,
  pnt_in_poly_algorithm = 1,
  pnt_in_poly_epsilon = 1e-12,
  display_progress = TRUE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

pops

a list of population(s) to add to 'obj'. Each element of this list will be coerced by buildPopulation.

pnt_in_poly_algorithm

algorithm used to determine if object belongs to a polygon region or not. Default is 1.
Note that for the moment only 1(Trigonometry) is available.

pnt_in_poly_epsilon

epsilon to determine if object belongs to a polygon region or not. It only applies when algorithm is 1. Default is 1e-12.

display_progress

whether to display a progress bar. Default is TRUE.

...

Other arguments to be passed.

Details

A warning will be thrown if a provided population is already existing in 'obj'.
In such a case this population will not be added to 'obj'.
If any input population is not well defined and can't be created then an error will occur.

Value

an IFC_data object with pops added.

Source

For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  ## copy 1st population from existing daf
  pop <- daf$pops[[1]]
  if(length(pop) != 0) {
    pop_copy <- pop
    ## modify name, obj and type of copied population
    pop_copy$name <- paste0(pop_copy$name,"_copy")
    pop_copy$obj <- (which(pop_copy$obj)-1)[1]
    pop_copy$type <- "T"
    ## create new object with this new population
    dafnew <- data_add_pops(obj = daf, pops = list(pop_copy))
  }
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Add Region to IFC_data Object

Description

Adds regions to an already existing 'IFC_data' object.

Usage

data_add_regions(obj, regions, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

regions

a list of region(s) to add to obj. Each element of this list will be coerced by buildRegion.

...

Other arguments to be passed.

Details

A warning will be thrown if a provided region is already existing in 'obj'.
In such a case this region will not be added to 'obj'.
If any input population is not well defined and can't be created then an error will occur.

Value

an IFC_data object with regions added.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  ## copy 1st region found in daf
  reg <- daf$regions[[1]]
  if(length(reg) != 0) {
    reg_copy <- reg
    ## modify region label and x boundaries
    reg_copy$label <- paste0(reg_copy$label,"_copy")
    reg_copy$x <- reg_copy$x*0.9
    ## create new object with this new region
    dafnew <- data_add_regions(obj = daf, regions = list(reg_copy))
  }
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Modify Populations within IFC_data Object

Description

Modify populations in an already existing 'IFC_data' object.

Usage

data_modify_pops(obj, pops, display_progress = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

pops

a list of population(s) to modify in 'obj'. Each element of this list will be coerced by buildPopulation.

display_progress

whether to display a progress bar. Default is TRUE.

...

Other arguments to be passed.

Details

pops names should be present in names(obj$pops), otherwise an error will be raised.
Note that If you want to rename pops, you should do it by changing 'name' member, e.g. pops[[1]]$name <- "bar" while names(pops[[1]]) is "foo" and "foo" is part of names(obj$pops). However, new names should not be present in 'obj'.

Value

an IFC_data object with pops modified.


Modify Populations within IFC_data Object

Description

Modify populations in an already existing 'IFC_data' object.

Usage

data_modify_regions(obj, regions, display_progress = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

regions

a list of region(s) to modify in 'obj'. Each element of this list will be coerced by buildRegion.

display_progress

whether to display a progress bar. Default is TRUE.

...

Other arguments to be passed.

Details

regions names should be present in names(obj$regions), otherwise an error will be raised.
Note that If you want to rename regions, you should do it by changing 'label' member, e.g. regions[[1]]$label <- "bar" while names(regions[[1]]) is "foo" and "foo" is part of names(obj$regions).

Value

an IFC_data object with regions modified.


Remove Features from an IFC_data Object

Description

Removes regions from an already existing 'IFC_data' object.

Usage

data_rm_features(obj, features, list_only = TRUE, adjust_graph = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

features

a character vector of features names to remove within 'obj'. Note that "Object Number" is not allowed and will be excluded from 'features' if present.

list_only

whether to return a list of elements that will be impacted by the removal. Default is TRUE. If FALSE then modified object will be returned.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, graph(s) will be removed no matter if features, regions, pops it refers to are found in 'obj'.

...

Other arguments to be passed.

Value

an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.


Remove Graph from an IFC_data Object

Description

Removes graphs from an already existing 'IFC_data' object.

Usage

data_rm_graphs(obj, graphs, list_only = TRUE, adjust_graph = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

graphs

an integer vector of graph(s) to remove within 'obj'.

list_only

whether to return a list of elements that will be impacted by the removal. Default is TRUE. If FALSE then modified object will be returned.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, graph(s) will be removed no matter if features, regions, pops it refers to are found in 'obj'.

...

Other arguments to be passed.

Value

an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.


Remove Population from an IFC_data Object

Description

Removes populations from an already existing 'IFC_data' object.

Usage

data_rm_pops(obj, pops, list_only = TRUE, adjust_graph = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

pops

a character vector of population names to remove within 'obj'. Note that "All" and "" are not allowed and will be excluded from 'pops' if present.

list_only

whether to return a list of elements that will be impacted by the removal. Default is TRUE. If FALSE then modified object will be returned.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, graph(s) will be removed no matter if features, regions, pops it refers to are found in 'obj'.

...

Other arguments to be passed.

Value

an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.


Remove Region from an IFC_data Object

Description

Removes regions from an already existing 'IFC_data' object.

Usage

data_rm_regions(obj, regions, list_only = TRUE, adjust_graph = TRUE, ...)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

regions

a character vector of regions names to remove within 'obj'.

list_only

whether to return a list of elements that will be impacted by the removal. Default is TRUE. If FALSE then modified object will be returned.

adjust_graph

whether to try to adjust graph(s) when possible. Default is TRUE.
-TRUE, graph(s) will be kept if possible using only regions, pops it depends that can be found in 'obj',
-FALSE, graph(s) will be kept only if all features, regions, pops it refers to are found in 'obj',
-NA, graph(s) will be removed no matter if features, regions, pops it refers to are found in 'obj'.

...

Other arguments to be passed.

Value

an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.


AST File Writer

Description

Writes an 'IFC_data' object to a ast file

Usage

data_to_AST(
  obj,
  write_to,
  viewing_pop = "All",
  overwrite = FALSE,
  display_progress = TRUE,
  verbose = FALSE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'obj$fileName'
-%p: with first parent directory of 'obj$fileName'
-%e: with extension of 'obj$fileName' (without leading .)
-%s: with shortname from 'obj$fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that it has to be a .ast.

viewing_pop

Character String. Allow user to change displayed population. Default is 'All'.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite exported file if path of 'obj$fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

display_progress

whether to display a progress bar. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

...

other arguments to be passed.

Value

It invisibly returns full path of exported file.


DAF File Writer

Description

Writes an 'IFC_data' object to a daf file

Usage

data_to_DAF(
  obj,
  write_to,
  viewing_pop = "All",
  overwrite = FALSE,
  binary = TRUE,
  endianness = .Platform$endian,
  display_progress = TRUE,
  verbose = FALSE,
  fullname = TRUE,
  cifdir = dirname(obj$fileName),
  ntry = +Inf,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'obj$fileName'
-%p: with first parent directory of 'obj$fileName'
-%e: with extension of 'obj$fileName' (without leading .)
-%s: with shortname from 'obj$fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that it has to be a .daf.

viewing_pop

Character String. Allow user to change displayed population. Default is 'All'.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite exported file if path of 'obj$fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

binary

whether to write object to file in binary mode or not. Default is TRUE.
Note that it can represent a convenient way to make file written in binary mode back-compatible with former version of IDEAS software.
/!\ However unexpected behaviour may happen if features, regions, pops, ... are depending on masks (e.g. AdaptiveErode, Component, LevelSet, Watershed) introduced in newer version of IDEAS software.
/!\ Important please note that conversion from binary to non-binary and back to binary may create some rounding adjustment resulting in some features/image values changes.
Finally, if data originate from FCS, 'binary' will be forced to FALSE.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

display_progress

whether to display a progress bar. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

fullname

whether to export daf file with full name of its corresponding cif, if found. Default is TRUE. If cif can't be found, daf file will be exported with the original cif file name.

cifdir

the path of the directory to initially look to cif file. Default is dirname(obj$fileName). Only apply when 'fullname' is set to TRUE.

ntry

number of times data_to_DAF will be allowed to find corresponding cif file. Default is +Inf. Only apply when 'fullname' is set to TRUE.

...

other arguments to be passed.

Value

It invisibly returns full path of exported file.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  tmp <- tempdir(check = TRUE)
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  ## add a new population to daf
  dafnew <- data_add_pops(daf, list(buildPopulation(name = "test", type = "T", obj = 0)))
  ## export obj to file using binary mode
  data_to_DAF(obj = dafnew, write_to = paste0(tmp, "\\test_bin.daf"),
              overwrite = TRUE, binary = TRUE)
  ## exporting to non binary mode
  data_to_DAF(obj = dafnew, write_to = paste0(tmp, "\\test_notbin.daf"),
              overwrite = TRUE, binary = FALSE)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Colors for Smooth Density Plots

Description

Helper to map density to colors

Usage

densCols(
  x,
  y = NULL,
  xlim = range(x, na.rm = TRUE, finite = TRUE),
  ylim = range(y, na.rm = TRUE, finite = TRUE),
  nbin = 128,
  colramp = colorRampPalette(c("blue", "green", "red")),
  transformation = "asinh"
)

Source

derived from grDevices R Core Team, Florian Hahne at FHCRC, originally


Progress Bar Terminator

Description

Terminates a progress bar.

Usage

endPB(pb)

Arguments

pb

an object of class 'IFC_progress' containing a progress bar of class 'txtProgressBar', 'winProgressBar' or 'Progress'.


XML Entities Protection

Description

Helper to escape xml entities.

Usage

escape_entities(text)

Arguments

text

value return by xml2::as_list. Default is 5.

Details

entities will be replaced by:
-& to "&amp;"
-> to "&gt;"
-< to "&lt;"
-' to "&apos;"
-" to "&quot;"

Value

a character vector where xml entities have been escaped.


XML Node List Expansion

Description

Helper to stringify XML node.

Usage

expand_list(x, max = 5)

Arguments

x

value return by xml2::as_list.

max

maximum number of recurrence into subnodes. Default is 5.


Statistics Extraction

Description

Extracts statistics from 'IFC_data' object

Usage

extractStats(obj, feat_name, trans = "P")

Arguments

obj

an 'IFC_data' object

feat_name

a feature name.

trans

character string describing transformation used and its parameters. See parseTrans().

Value

a data.frame with computed statistics.


Any with Rcpp

Description

Helper to compute any

Usage

fastAny(x)

Arguments

x

either a list or an object coercible to logical matrix

Details

if 'x' is a list it will return any across list members. if 'x' is coercible to a logical matrix, it will return any across matrix rows

Value

a logical vector


Combine by Columns

Description

Helper to combine by columns

Usage

fastCbind(obj1, obj2, add_id = FALSE)

Arguments

obj1

an object either a data.frame, a list or something coercible to numeric matrix.

obj2

an object either a data.frame, a list or something coercible to numeric matrix.

add_id

a bool determining if 1st column of returned object should be given 1 to nrow integers

Details

if obj1 or obj2 is a data.frame returned object will inherit class of obj1 or obj2 respectively in this order. /!\ if obj1 or obj2 needs to be coerced take care that it can not handle factor during object coercion

Value

a combined object


List IFC features

Description

Helper to give the list of available features

Usage

featureIFC()

Value

a list of all features


Feature Default Name Computation

Description

Helper to compute default name of a feature.

Usage

feature_namer(feat_def)

Arguments

feat_def

list containing feature definition

Value

a string with default name


Seed Instructions Extraction

Description

Retrieve seed instructions from input

Usage

fetch_seed(seed = NA_integer_)

Arguments

seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL. NA_integer_ or list(seed = NA_integer_) can be used to prevent 'seed' argument from being passed to set.seed. Default is NA_integer_.


File Path Placeholders Formatting

Description

Helper to format splitp_obj using splitf_obj, channel and object information.

Usage

formatn(splitp_obj, splitf_obj, channel = "", object = "")

Arguments

splitp_obj

object returned by splitp.

splitf_obj

object returned by splitf. It will be used to substitute %d, %p, %s and %e.

channel

string to be used to substitute %c

object

string to be used to substitute %o


GatingML Conversion from XML2

Description

Helper to convert boolean and graphical pops and corresponding regions from XML nodes in GatingML files.

Usage

fromXML2_gating(xml_nodes, type = "rect")

Arguments

xml_nodes

a set of xml_nodes

type

type of the gate to extract

Value

a list of:
-region, region information
-pop, population information


Alternative Names Generator

Description

Generates unique non matching alternative names

Usage

gen_altnames(
  x,
  n = 10,
  forbidden = character(),
  random_seed = list(seed = 252, "Mersenne-Twister", "Inversion", "Rounding")
)

Arguments

x

a character vector.

n

number of characters of the desired returned name. Default is 10.

forbidden

forbidden character vector. Default is character().

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL. Default is list(seed = 0xFC, "Mersenne-Twister", "Inversion", "Rounding"). Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all. Note also that the default is chosen because it is compatible with old R version.

Details

'forbidden' should not encompass all possible returned value otherwise the function will never end.

Value

a character vector.


ASSIST Database Extraction

Description

Retrieves ASSIST tests values stored within .cif / .rif files.

Usage

getASSIST(fileName, ...)

Arguments

fileName

path to file..

...

other arguments to be passed.

Value

a list of class 'IFC_assist' of parsed ASSIST tests database.


Aborted Batch Files Retrieval

Description

Try to retrieve files whose processing failed during batch. This is a very beta version

Usage

getAborted(aborted, default_batch_dir, config_file)

Arguments

aborted

path to file containing aborted information.
If missing, the default, a dialog box will be displayed to choose this file. Note, that if provided 'default_batch_dir' and 'config_file' will not be used.

default_batch_dir

directory where batches are stored.
It can be found in IDEAS(R) software, under Options -> Application Defaults -> Directories -> Default Batch Report Files Directory. If missing, the default, it will be deduced from IDEAS(R) config file, However, if it can't be deduced then current working directory will be used.
This argument takes precedence over 'config_file' and filling 'default_batch_dir' prevents the use of 'config_file' argument.

config_file

path to IDEAS(R) config file.
It may depends on IDEAS(R) software installation but one may use "C:/Users/%USER%/AppData/Roaming/Amnis Corporation/userconfig.xml".

Value

a list of 4 elements:
-not_existing: a list of files paths that caused failure because they were not found during batch,
-not_handled: a list of failed files and the retrieved error message.
-failed_found: a list of failed files and their unique corresponding paths,
-failed_match: a list of failed files and their all paths that could match.


Features Values Extraction

Description

Extracts features values according to features definitions

Usage

getFeaturesValues(
  features,
  features_def,
  operators = c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT"),
  split = "|",
  ...
)

Arguments

features

a data.frame of features, typically an object of class 'IFC_features'.

features_def

a list of features definitions, typically an object of class 'IFC_features_def'.

operators

operators used. Default is c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT").

split

string used for splitting. Default is "|".

Value

a data.frame of features values.


File Extension Retrieval

Description

Determines extension from alpha numeric file name.

Usage

getFileExt(x)

Arguments

x

path to file.

Value

the file extension in lower case if found. Otherwise, "".

Source

derived from file_ext() in tools, R Core Team, Kurt Hornik and Friedrich Leisch.


Image Field Directory Full Tag Retrieval

Description

Retrieves full tag value from IFDs (Image Field Directory) extracted by getIFD.

Usage

getFullTag(IFD, which = 1, tag = "256", raw = FALSE)

Arguments

IFD

an object of class 'IFC_ifd_list' extracted by getIFD.

which

scalar, integer (index) or the name of 'IFD' sub-element to extract 'tag' from. Default is 1 to extract 'tag' from the first member of 'IFD'.

tag

scalar, integer (index) or the name of the IFD[[which]] of the desired 'tag'.

raw

whether to return tag as a raw vector. Default is FALSE.

Details

It may be usefull to extract all information contained in a specific 'tag' since getIFD is designed to be run with argument trunc_bytes so as to only extract essential bytes to run faster and save memory. Nonetheless, thanks to getFullTag users will still be able to get full extraction of specific tag.

Value

the full value of the corresponding IFD tag.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html


RIF/CIF Image Field Directories Extraction

Description

Extracts IFDs (Image File Directory) in RIF or CIF files.
IFDs contain information about images or masks of objects stored within XIF files.
The first IFD is special in that it does not contain image of mask information but general information about the file.
Users are highly encouraged to read TIFF specifications to have a better understanding about what IFDs are.

Usage

getIFD(
  fileName,
  offsets = "first",
  trunc_bytes = 12,
  force_trunc = FALSE,
  verbose = FALSE,
  verbosity = 1,
  display_progress = FALSE,
  bypass = FALSE,
  ...
)

Arguments

fileName

path to file.

offsets

either "all", "first" or an object of class 'IFC_offset'. Default is "first".

trunc_bytes

a positive integer maximal number of individual scalar to extract BYTE/ASCII/SBYTE/UNDEFINED for TAGS (1, 2, 6 or 7). Default is 12.
However, if less is found, less is returned in map. Note that, if 0 is provided, it will be automatically set to 1.

force_trunc

whether to force truncation for all TAGS types. Default is FALSE.
If TRUE, 'trunc_bytes' will be used for TAGS (3, 4, 5, 8, 9, 10, 11 and 12) to extract desired number of individual scalar corresponding to each types.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

display_progress

whether to display a progress bar. Default is FALSE.

bypass

whether to bypass checks on 'trunc_bytes', 'force_trunc', 'verbose', 'verbosity' and 'display_progress'. Default is FALSE.

...

other arguments to be passed.

Details

Function will return IFDs (image, mask or first) from the file using provided offsets argument.
IFDs contain several tags that can be viewed as descriptive meta-information of raw data stored within RIF or CIF file. For more details see TIFF specifications.
If 'offsets' == "first" only first IFD will be returned.
If 'offsets' == "all" all images and masks IFDs will be returned but not "first" one. Be aware that errors may occur if offsets are not extracted with getOffsets or subsetOffsets.

Value

A list of named lists, each containing:
-tags, a named list whose names are tags found, where each tag is a list of tag, typ, siz, val, byt, len, off, map information.
-infos, a named list containing essential information about IFDs, IMAGE_LENGTH, IMAGE_WIDTH, OBJECT_ID, COMPRESSION, TYPE, STRIP_OFFSETS, STRIP_BYTE_COUNTS, BG_MEAN, BG_STD
-curr_IFD_offset, the position of current IFD offset
-next_IFD_offset, the position of next IFD offset

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  ## read 1st IFD
  IFD_first <- getIFD(fileName = file_cif, offsets = "first")
  ## show information contained in 1st IFD
  print(sapply(IFD_first[[1]]$tags, FUN=function(x) x)) 
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

RIF/CIF Image Values Extraction

Description

Extracts the image values from RIF or CIF as what can be found in DAF files

Usage

getImagesValues(
  fileName,
  offsets,
  objects,
  display_progress = FALSE,
  fast = TRUE,
  ...
)

Arguments

fileName

path to file.

offsets

Object of class ‘IFC_offset'. If missing, the default, ’offsets' will be extracted from 'fileName'.
This param is not mandatory but it may allow to save time when exporting repeated image value on same file.

objects

integer vector, IDEAS objects ids numbers to extract.
If missing, the default, images values from all objects will be extracted.

display_progress

whether to display a progress bar. Default is FALSE.

fast

when no 'offsets' are provided whether to fast extract 'objects' or not. Default is TRUE.
Meaning that 'objects' will be extracted expecting that 'objects' are stored in ascending order.
Only apply when 'offsets' are not provided.
Note that a warning will be sent if an object is found at an unexpected order.

...

other arguments to be passed.

Value

A data.frame is returned.


IFC File Information Extraction

Description

Retrieves rich information from RIF, CIF and DAF files.

Usage

getInfo(
  fileName,
  from = c("acquisition", "analysis")[2],
  verbose = FALSE,
  verbosity = 1,
  warn = TRUE,
  force_default = TRUE,
  cifdir = dirname(fileName),
  ntry = +Inf,
  ...
)

Arguments

fileName

path to file..

from

whether to extract information from 'acquisition' or 'analysis'. Default is 'analysis'.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information print to console when verbose is TRUE; 1: normal, 2: rich. Default is 1.

warn

whether to send warning message when trying to read 'analysis' information from a 'rif' file. Default is TRUE.

force_default

when display information can't be retrieved whether to use default values. Default is TRUE.

cifdir

the path of the directory to initially look to cif file. Default is dirname(fileName). Only apply when 'fileName' is a .daf file.

ntry

number of times getInfo will be allowed to find corresponding cif file. Default is +Inf. Only apply when 'fileName' is a .daf file. If cif can't be found, but 'ntry' is reached, then an error will be thrown.

...

other arguments to be passed.

Value

a list of information (open .daf file in an text editor for more details) about input fileName of class 'IFC_info' and 'acquistion' or 'analysis', whose members are:
-objcount, number of object in file,
-date, date of file creation,
-instrument, instrument identification,
-sw_raw, version of software for raw data,
-sw_processed, version of software for processed data,
-channelwidth, default channel width in pixel,
-in_use, channels used,
-brightfield, whether brightfield is applied on channels and its intensity,
-illumination, laser illumination parameters,
-collectionmode, the collection mode,
-magnification, magnification used,
-coremode, the core mode,
-evmode, the high gain mode,
-CrossTalkMatrix. compensation matrix applied,
-ChannelPresets, channel preset,
-ImageDisplaySettings, image display settings,
-Images, information about colors, range and channels,
-masks, masks defined,
-ViewingModes, modes of visualization,
-checksum, checksum computed,
-Merged_rif, character vector of path of files used to create rif, if input file was a merged,
-Merged_cif, character vector of path of files used to create cif, if input file was a merged,
-XIF_test, integer defining XIF type,
-checksum, integer corresponding to file checksum,
-fileName, path of fileName input,
-fileName_image, path of fileName_image.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  info <- getInfo(fileName = file_daf, from = "analysis")
  ## show some information
  print(info$Images)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Luminance Computation

Description

Determines color's luminance.

Usage

getLuminance(color)

Arguments

color

a character string.


RIF/CIF File Image Field Directories Offsets Extraction

Description

Extracts offsets of the IFDs (Image Field Directories) within a XIF file. Users are highly encouraged to read TIFF specifications to have a better understanding about what offsets and IFDs are.

Usage

getOffsets(fileName, fast = TRUE, display_progress = TRUE, verbose = FALSE)

Arguments

fileName

path to file.

fast

whether to fast extract 'objects' or not. Default is TRUE.
Meaning that offsets will be extracted expecting that 'objects' are stored in ascending order.
A message will be thrown since fast extraction method does not ensure correct mapping between objects and offsets.
If set to FALSE, all object_ids will be scanned from 'fileName' to ensure extraction of desired offsets.

display_progress

whether to display a progress bar. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

Details

Offsets are byte positions of IFDs found within RIF or CIF file. For more details see TIFF specifications.

Value

an integer vector of class 'IFC_offset' of IFDs offsets found in XIF file.

Source

TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  system.time(offsets_fast <- getOffsets(fileName = file_cif, fast = TRUE))
  system.time(offsets_slow <- getOffsets(fileName = file_cif, fast = FALSE))
  identical(offsets_fast, offsets_slow)   
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Statistics Report Template Extraction

Description

Retrieves statistics report template from .ast / .daf files.

Usage

getSTATSREPORT(fileName)

Arguments

fileName

path to file.

Details

Allowed 'statistics' names are: "Count","Mean","%Total","%Gated","%","Objects/mL","RD - Mean", "Median","CV","stddev","NaN","MAD","min","RD - Median","Variance","max","geomean","Mode".
For "%Total","%Gated","%","RD - Mean","RD - Median", 'type' has to be "ratio" and both 'population1' and 'population2' should be provided. Otherwise, 'type' is "value" and only 'population1' is mandatory.
/!\ Note that "Mode" and "Objects/mL" can't be determined and will result in NA.

Value

a 6-columns character matrix describing report instructions:
- 'name', for the desired name of exported 'statistics',
- 'type', for the type of stats to return (either "value" or "ratio"),
- 'population1', determines the population on which 'statistics' will be performed,
- 'population2', determines the reference population (when 'type' is "ratio", see Details),
- 'feature', determines the feature's name on which 'statistics' will be computed,
- 'statistics', controls the mathematical function that will be applied (see Details).


Device Adjusted Coordinates

Description

Helper to extract current device plotting region adjusted to device size

Usage

get_coordmap_adjusted(
  coordmap,
  width = grDevices::dev.size("px")[1],
  height = grDevices::dev.size("px")[2],
  ratio = graphics::par("din")/graphics::par("pin")
)

Arguments

coordmap

current device plotting region. Default is missing.

width

current device height in pixel. Default is grDevices::dev.size("px")[1].

height

current device width in pixel. Default is grDevices::dev.size("px")[2].

ratio

current device ratio. Default is graphics::par('din') / graphics::par('pin').

Source

computes drawing region in a similar way as shiny:::getPrevPlotCoordmap()


Device Raw Coordinates

Description

Helper to extract current device plotting region

Usage

get_coordmap_raw()

Source

computes drawing region in a similar way as shiny:::getPrevPlotCoordmap()


Feature Values Computation

Description

Computes feature values from feature definition

Usage

get_feat_value(
  feat_def,
  features,
  alt_names,
  operators = c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT"),
  split = "|"
)

Arguments

feat_def

a feature definition as created by buildFeature.

features

a data.frame of features, typically an object of class 'IFC_features'.

alt_names

vector of same length as features to use for substitution. It can be used to speed up the process.

operators

operators used. Default is c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT").

split

string used for splitting. Default is "|".

Details

if 'feat_def$type' is "combined" returned value will be computed according in the scope of 'features' according to 'feat_def$def'. Otherwise, 'feat_def$name' will be searched in 'features' to return value, and if not found 'feat_def$val' will be returned.

Value

a vector of feature values.


Statistics Extraction from Populations

Description

Extracts populations statistics

Usage

get_pops_stats(pops, objcount = 0)

Arguments

pops

list of populations

objcount

total number of objects.

Value

a data.frame with computed statistics.


Histogram y-Axis Limits Constructor

Description

Helper to extract ylim

Usage

get_ylim(x, type, br, include.lowest = TRUE, right = TRUE)

Source

derived from lattice from Deepayan Sarkar


Groups Combination

Description

Combines data.frame groups into a unique one

Usage

group(df, collapse = ".", keepNAlevels = FALSE, ...)

Arguments

df

a data.frame whose columns represent grouping factor.

collapse

a string used to collapse groups levels.

keepNAlevels

whether to keep NA levels resulting from groups merging

...

other arguments to be passed.

Value

a named list containing row indices of grouping combinations.


String Sequence Replacement

Description

Replaces a sequence of strings

Usage

gseq(x, pattern = "", replacement = character(), all = TRUE)

Arguments

x, pattern, replacement

non empty character vectors.

all

whether to replace all instances of 'pattern' or only the 1st one. Default is TRUE, to replace all instances.

Details

if 'pattern' is found within 'x', 'pattern' will be removed from 'x' and replace by 'replacement'.
It looks like gsub but it is different e.g.:
x=c("ABD","A","B")
pattern=c("A","B")
replacement=c("C")
- gsub(x=paste0(x,collapse=""),pattern=paste0(pattern,collapse=""),replacement=paste0(replacement,collapse=""),fixed=TRUE) will give "CDC",
- gseq(x=x,pattern=pattern,replacement=replacement) will give "ABD","C".

Value

'x' where 'pattern' is replaced by replacement.


Histogram Constructor

Description

Helper to construct histogram

Usage

hist_constr(x, breaks, include.lowest = TRUE, right = TRUE, ...)

Hexadecimal to Integer Color Conversion

Description

Helper to convert color from hex

Usage

inv_colConv(col)

Inverse Smooth Asinh Transformation

Description

Gets values back just to their original values before applying smoothAsinh

Usage

inv_smoothAsinh(x, hyper = 1000)

Inverse Smooth LinLog Transformation

Description

Gets values back just to their original values before applying smoothLinLog.

Usage

inv_smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))

Arguments

x

A numeric vector.

hyper

value where transition between Lin/Log is applied.

base

base of Log scale.

lin_comp

value that is used to smooth transition between Lin/Log. Default is log(base).

Value

the inverse smoothLinLog transformation of the input.


Report Layout Extraction

Description

Extracts report layout from 'IFC_graphs' object.

Usage

layoutReport(graphs)

Arguments

graphs

an 'IFC_graphs' object extracted with features extracted.

Value

a list containing:
-lay, a 3 columns (N, x, y) data.frame, where N is the graph index and x and y its coordinates on the layout,
-mat, a matrix describing the layout.


Color Mapping

Description

Converts IDEAS/INSPIRE colors toR and inversely

Usage

map_color(color, toR = TRUE)

Arguments

color

a character vector Default is missing.

toR

whether to convert color toR or back. Default is TRUE.

Value

a character vector.


Style Mapping

Description

Converts IDEAS/INSPIRE style toR and inversely

Usage

map_style(style, toR = FALSE)

Arguments

style

a pch (converted to integer) or a character vector. Default is missing.

toR

whether to convert color toR or back. Default is FALSE.

Value

an integer vector when toR is TRUE or a character vector.


RIF/CIF File Merging

Description

Merges RIF or CIF files.

Usage

mergeXIF(
  fileName,
  write_to,
  extract_features = FALSE,
  endianness = .Platform$endian,
  verbose = FALSE,
  verbosity = 1,
  overwrite = FALSE,
  display_progress = TRUE,
  add_tracking = TRUE,
  ...
)

Arguments

fileName

paths of files to merge. All files have to be either '.rif' or '.cif' files. All files should have same channels.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of first element of 'fileName'
-%p: with first parent directory of first element of 'fileName'
-%e: with extension of 'fileName' (without leading .)
-%s: with shortname from of first element of 'fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. It has to be the same as 'fileName', i.e. .cif or .rif.

extract_features

whether to try to extract features. Default is FALSE. Not yet implemented.

endianness

the endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

overwrite

whether to overwrite file or not. Default is FALSE.
Note that if TRUE, it will overwrite exported file if paths of files in 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

display_progress

whether to display a progress bar. Default is TRUE.

add_tracking

whether to register files' paths and objects' ids in the exported file. Default is TRUE.

...

other arguments to be passed.

Value

It invisibly returns full path of exported file.


Image Gamma Modification

Description

Determines best xmid, ymid computes ymid for a given gamma

Usage

modifyGamma(V, gamma = 1)

Arguments

V

named NumericVector of channel display properties containing 'xmin', 'xmax', 'xmid' and 'ymid'.

gamma

gamma


Scale Constructor for IFC Graphs Plotting

Description

Helper to rescale and label axes

Usage

myScales(x = list(), y = list())

Progress Bar Initializer

Description

Initializes a progress bar.

Usage

newPB(
  title,
  label,
  min = 0,
  max = 1,
  initial = 0,
  steps = 21,
  width,
  style,
  char = "=",
  file = "",
  ...
)

Arguments

title, label

character strings, giving the 'title'(='message' for shiny progress bar) and the 'label'(='detail' for shiny progress bar).

min, max

(finite) numeric values for the extremes of the progress bar. Must have 'min' < 'max'.

initial

initial value for the progress bar.

steps

(finite) numeric value for the number of individual chunk of the progress bar. Default is 21.

width

the width of the progress bar. If missing, the default, will be NA for "txtProgressBar" and 300 for "winProgressBar".

style

does not apply for "winProgressBar", the style of the bar. If missing, the default, will be 3 "txtProgressBar" and getShinyOption("progress.style", default = "notification") for shiny progress bar.

char

only apply for "txtProgressBar", the character (or character string) to form the progress bar.

file

only apply for "txtProgressBar", an open connection object or "" which indicates the console: stderr() might be useful here. Default is "".

...

Other arguments to be passed.

Details

shiny progress bar will be available only if shiny package is found and within a shiny app.

Value

pb an object of class 'IFC_progress' containing a progress bar of class 'txtProgressBar', 'winProgressBar' or 'Progress'.


Next Component Prediction

Description

Helper to define next allowed component in a boolean vector.

Usage

next_bool(x = "", count = 0L, obj_alias)

Arguments

x

a string, current component.

count

an integer, representing current number of opened/closed bracket.

obj_alias

a string, alias used for population name.

Value

a vector of next allowed components.


Numeric to String Formatting

Description

Formats numeric to string used for features, images, ... values conversion when exporting to xml.

Usage

num_to_string(x, precision = 22)

Arguments

x

a numeric vector.

precision

number of significant decimal digits to keep. Default is 22.

Value

a string vector.


Object Cleanser

Description

Removes abnormalities (clipped/debris) from image.

Usage

objectCleanse(mat, msk, add_noise = TRUE, random_seed = NULL, bg = 0, sd = 0)

Arguments

mat

a numeric matrix (image).

msk

a numeric matrix (mask identifying abnormalities).

add_noise

if TRUE adds normal noise to background using rnorm(), from Rcpp. Default is TRUE.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

bg

mean value of the background added if add_noise is TRUE. Default is 0.

sd

standard deviation of the background added if add_noise is TRUE. Default is 0.

Value

According to msk, pixel values in mat are substituted by either bg [add_noise == FALSE] or rnorm(n = prod(dim(mat), mean=bg, sd=sd)) [add_noise == TRUE].


Object Colorizer

Description

Colorizes a [0,1] grayscale image.

Usage

objectColorize(mat, color)

Arguments

mat

a [0,1] numeric matrix.

color

a color

Value

a 3D array where 3rd dimension is rgb.


Object Display

Description

This function is intended to display object extracted by objectExtract.

Usage

objectDisplay(
  image,
  input_range = c(0, 4095),
  full_range = FALSE,
  force_range = FALSE,
  gamma = 1,
  color = "Green",
  dpi = 300
)

Arguments

image

An object extracted by objectExtract of class 'IFC_img' or 'IFC_msk'.
Note that a matrix with finite values can also be used.

input_range

a finite numeric vector of 2 values, sets the range of the input intensity values. Values outside this range are clipped. Default is [0,4095].

full_range

if 'full_range' is TRUE, then 'input_range' will be set to [0,4095] and 'gamma' forced to 1. Default is FALSE.

force_range

if 'force_range' is TRUE, then 'input_range' will be adjusted to 'image' range in [-4095,+inf] and 'gamma' forced to 1. Default is FALSE.
Note that this parameter takes the precedence over input_range' and full_range'.

gamma

'gamma' correction. Default is 1, for no correction.

color

a color. Default is "Green".

dpi

display resolution. Default is 300.

Details

If 'image' is of class 'IFC_img' or 'IFC_msk', then if 'input_range', 'full_range', 'force_range', 'gamma' and/or 'color' parameters is/are missing, it/they will be extracted from 'image' attributes.
If 'image' is not of one of class 'IFC_img' or 'IFC_msk', then 'force_range' will be forced to TRUE.
An error will be thrown if input image contains non finite values.

Value

it invisibly returns NULL


Object Extraction

Description

Extracts / Decompress objects stored in RIF or CIF Files.

Usage

objectExtract(ifd, param, verbose = FALSE, bypass = FALSE, ...)

Arguments

ifd

list of sub elements of IFD data information extracted by getIFD. This argument can't be missing.

param

object of class 'IFC_param', containing extraction parameters defined by objectParam.
This argument is not mandatory but it may allow to save time for repeated image export on same file. If this argument is missing, objectExtract will use named arguments in '...' as input to objectParam to control object extraction.
However, if 'param' is provided, '...' will be ignored.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

bypass

whether to bypass checks on 'ifd' and 'param'. Default is FALSE.

...

Arguments passed on to objectParam

info

object of class 'IFC_info', rich information extracted by getInfo. This argument is not mandatory but it may allow to save time for repeated image export on same file. If missing, the default, 'info' will be extracted thanks to '...'.

mode

color mode export. Either "rgb", "gray" or "raw". Default is "raw". Note that "raw" is only possible when 'export' is "matrix".

export

format mode export. Either "file", "matrix", "base64". Default is "matrix".

write_to

used when export is "file" or "base64" to compute respectively exported file name or base64 id attribute.
Exported file extension and base64 MIME type will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" are faster but not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory,
-%p: with first parent directory,
-%e: with extension (without leading .),
-%s: with shortname (i.e. basename without extension),
-%o: with object_id,
-%c: with channel_id.
A good trick is to use:
-"%d/%s/%s_%o_%c.tiff", when 'export' is "file",
-"%o_%c.bmp", when 'export' is "base64".
Note that if missing and 'export' is not "file", 'write_to' will be set to "%o_%c.bmp".

base64_id

whether to add id attribute to base64 exported object. Default is FALSE.
Only applied when export is "base64".

base64_att

attributes to add to base64 exported object. Default is "".
Only applied when export is "base64". For example, use "class='draggable'".
Note that id (if 'base64_id' is TRUE) and width and height are already used.

overwrite

only apply when 'export' is "file" whether to overwrite file or not. Default is FALSE.

composite

character vector of image composite. Default is "", for no image composite.
Should be like "1.05/2.4/4.55" for a composition of 5 perc. of channel 1, 40 perc. of channel 2 and 50 perc. of channel 55.
Note that channels should have been acquired and final image composition should be 100 perc., otherwise an error is thrown.
Note that each composite will be appended after 'selection'.

selection

physical channels to extract.
Note that this parameter will be ordered.
Default is "all" to extract all acquired channels.
Use "none" to only extract composite.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

size

a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(0,0) for no change.

force_width

whether to use information in 'info' to fill size. Default is TRUE. When set to TRUE, width of 'size' argument will be overwritten.

removal

removal method: Either "none", "raw", "clipped", "masked", "MC".
-"none", to keep image as is, no mask extraction will be performed resulting in faster extraction,
-"raw", to keep image as is, it provides a convenient way to retrieve "raw" value for the mask,
-"clipped", to remove clipped object from image,
-"masked", to only keep masked object from image,
-"MC", to keep MC masked object from image. This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

add_noise

if TRUE adds normal noise to background using Rcpp. Default is TRUE.
Note that it is better to set it to FALSE when 'removal' is "masked" or "MC". Doing so will allow to place masked object in a zero filled background, otherwise background will still be filled with noise. This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

full_range

only apply when 'mode' is not "raw", if 'full_range' is TRUE, then object range will be considered as 0 to 4095, it is like "raw" 'mode' but resulting in [0,4095] normalization to [0,1]. Default is FALSE.
This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

force_range

only apply when 'mode' is not "raw", if 'force_range' is TRUE, then range will be adjusted to object range in [-4095,+inf] resulting in normalization to [0,1]. Default is FALSE.
This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.
Note that this parameter takes the precedence over 'full_range'.

spatial_correction

only apply on RIF file, whether to apply spatial correction. Default is FALSE.

Details

When a mask is detected, 'add_noise', 'full_range' and 'force_range' are set to FALSE and range used will be forced to [0,3].

Range of image is controlled by 'Images' information from supplied 'info' or as extracted by getInfo and will be returned as 'channels' by objectParam. In case 'mode' is not "raw", 'channels$xmin', 'channels$xmax', 'channels$gamma' will be used for object extraction by objectExtract unless any of 'force_range' or 'full_range' is TRUE.

Experimental (as of v0.2.0.501): once returned by objectParam, those 'channels$xmin' and 'channels$xmax' can be manually adjusted to ]0,1[ so as to be used as 'probs' argument to quantile to allow quantile normalization during object extraction (objectExtract) afterwards.

Value

A list (for every extracted objects) of list (for every exported channels) depending on 'param$export' parameter:
-"matrix", a matrix when 'param$mode' is set to "raw" or "gray" OR an array when 'param$mode' is "rgb",
-"base64", a data-uri string,
-"file", an invisible file path corresponding to the location of exported file(s).

Note

'...' will be used to compute 'param' only if 'param' is not provided.
/!\ When 'param' is not provided, if not any of 'fileName', 'info' can be found in '...', then attr(ifd, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

Source

For image decompression, Lee Kamentsky's code porting from https://github.com/ome/bioformats/blob/4146b9a1797501f0fec7d6cfe69124959bff96ee/components/formats-bsd/src/loci/formats/in/FlowSightReader.java
cited in https://linkinghub.elsevier.com/retrieve/pii/S1046-2023(16)30291-2
⁠ BSD implementations of Bio-Formats readers and writers Copyright (C) 2005 - 2017 Open Microscopy Environment: - Board of Regents of the University of Wisconsin-Madison - Glencoe Software, Inc. - University of Dundee Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ⁠

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  cif_offs <- getOffsets(fileName = file_cif, fast = TRUE)
  ## extract infomation
  info <- getInfo(fileName = file_cif, from = "analysis")
  ## retrieve number of objects stored
  nobj <- as.integer(info$objcount)
  ## randomly subset the offsets of at most 5 "img" objects
  sel = sample(0:(nobj-1), min(5, nobj))
  sub_offs <- subsetOffsets(cif_offs, objects = sel, image_type = "img")
  ## read IFDs from these "img" objects
  IFDs <- getIFD(fileName = file_cif, offsets = sub_offs)
  ## extract raw data of these"img" objects to matrix
  raw = objectExtract(ifd = IFDs, info = info, mode = "raw", 
                      export = "matrix")
  ## extract base64 "rgb" colorized version of these "img" objects to base64
  b64 = objectExtract(ifd = IFDs, info = info, mode = "rgb", 
                      export = "base64", base64_id = TRUE,
                      write_to = "example_%o_%c.bmp")
  ## use DisplayGallery to show the first "img" objects and play with ... extra parameters
  ## force_range, add_noise, selection, composite, see objectParam
  DisplayGallery(info = info, offsets = cif_offs, objects = sel,
                 base64_id = TRUE, write_to = "example_%o_%c.bmp",
                 force_range = c(FALSE,TRUE,FALSE,TRUE), add_noise = FALSE,
                 selection = c(1,2,4,6), composite = "1.7/4.3")
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Object Intensity Normalization

Description

Normalizes a matrix to [0,1].

Usage

objectNormalize(
  mat,
  input_range = c(0, 4095),
  full_range = FALSE,
  force_range = FALSE,
  gamma = 1
)

Arguments

mat

a finite numeric matrix.

input_range

a finite numeric vector of 2 values, sets the range of the input intensity values. Values outside this range are clipped. Default is [0,4095].

full_range

if 'full_range' is TRUE, then 'input_range' will be set to [0,4095] and 'gamma' forced to 1. Default is FALSE.

force_range

if 'force_range' is TRUE, then 'input_range' will be adjusted to 'mat' range in [-4095,+inf] and 'gamma' forced to 1. Default is FALSE.
Note that this parameter takes the precedence over input_range' and full_range'.

gamma

'gamma' correction. Default is 1, for no correction.

Details

Note that negative values are used internally for removal of unmasked objects.

Value

a [0,1] normalized matrix


Object Extraction Parameters Definition

Description

Defines 'IFC_object' object extraction parameters.

Usage

objectParam(
  ...,
  info,
  mode = c("rgb", "gray", "raw")[3],
  export = c("file", "matrix", "base64")[2],
  write_to,
  base64_id = FALSE,
  base64_att = "",
  overwrite = FALSE,
  composite = "",
  selection = "all",
  size = c(0, 0),
  force_width = TRUE,
  random_seed = NULL,
  removal = "none",
  add_noise = TRUE,
  full_range = FALSE,
  force_range = FALSE,
  spatial_correction = FALSE
)

Arguments

...

arguments to be passed to getInfo, only if 'info' is not provided.

info

object of class 'IFC_info', rich information extracted by getInfo. This argument is not mandatory but it may allow to save time for repeated image export on same file. If missing, the default, 'info' will be extracted thanks to '...'.

mode

color mode export. Either "rgb", "gray" or "raw". Default is "raw". Note that "raw" is only possible when 'export' is "matrix".

export

format mode export. Either "file", "matrix", "base64". Default is "matrix".

write_to

used when export is "file" or "base64" to compute respectively exported file name or base64 id attribute.
Exported file extension and base64 MIME type will be deduced from this pattern. Allowed export are ".bmp", ".jpg", ".jpeg", ".png", ".tif", ".tiff". Note that ".bmp" are faster but not compressed producing bigger data.
Placeholders, if found, will be substituted:
-%d: with full path directory,
-%p: with first parent directory,
-%e: with extension (without leading .),
-%s: with shortname (i.e. basename without extension),
-%o: with object_id,
-%c: with channel_id.
A good trick is to use:
-"%d/%s/%s_%o_%c.tiff", when 'export' is "file",
-"%o_%c.bmp", when 'export' is "base64".
Note that if missing and 'export' is not "file", 'write_to' will be set to "%o_%c.bmp".

base64_id

whether to add id attribute to base64 exported object. Default is FALSE.
Only applied when export is "base64".

base64_att

attributes to add to base64 exported object. Default is "".
Only applied when export is "base64". For example, use "class='draggable'".
Note that id (if 'base64_id' is TRUE) and width and height are already used.

overwrite

only apply when 'export' is "file" whether to overwrite file or not. Default is FALSE.

composite

character vector of image composite. Default is "", for no image composite.
Should be like "1.05/2.4/4.55" for a composition of 5 perc. of channel 1, 40 perc. of channel 2 and 50 perc. of channel 55.
Note that channels should have been acquired and final image composition should be 100 perc., otherwise an error is thrown.
Note that each composite will be appended after 'selection'.

selection

physical channels to extract.
Note that this parameter will be ordered.
Default is "all" to extract all acquired channels.
Use "none" to only extract composite.

size

a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(0,0) for no change.

force_width

whether to use information in 'info' to fill size. Default is TRUE. When set to TRUE, width of 'size' argument will be overwritten.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

removal

removal method: Either "none", "raw", "clipped", "masked", "MC".
-"none", to keep image as is, no mask extraction will be performed resulting in faster extraction,
-"raw", to keep image as is, it provides a convenient way to retrieve "raw" value for the mask,
-"clipped", to remove clipped object from image,
-"masked", to only keep masked object from image,
-"MC", to keep MC masked object from image. This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

add_noise

if TRUE adds normal noise to background using Rcpp. Default is TRUE.
Note that it is better to set it to FALSE when 'removal' is "masked" or "MC". Doing so will allow to place masked object in a zero filled background, otherwise background will still be filled with noise. This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

full_range

only apply when 'mode' is not "raw", if 'full_range' is TRUE, then object range will be considered as 0 to 4095, it is like "raw" 'mode' but resulting in [0,4095] normalization to [0,1]. Default is FALSE.
This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.

force_range

only apply when 'mode' is not "raw", if 'force_range' is TRUE, then range will be adjusted to object range in [-4095,+inf] resulting in normalization to [0,1]. Default is FALSE.
This parameter will be repeated with rep_len() from base for every physical channel that needs to be extracted according to 'selection' and 'composite' parameters.
Note that this parameter takes the precedence over 'full_range'.

spatial_correction

only apply on RIF file, whether to apply spatial correction. Default is FALSE.

Details

When a mask is detected, 'add_noise', 'full_range' and 'force_range' are set to FALSE and range used will be forced to [0,3].

Range of image is controlled by 'Images' information from supplied 'info' or as extracted by getInfo and will be returned as 'channels' by objectParam. In case 'mode' is not "raw", 'channels$xmin', 'channels$xmax', 'channels$gamma' will be used for object extraction by objectExtract unless any of 'force_range' or 'full_range' is TRUE.

Experimental (as of v0.2.0.501): once returned by objectParam, those 'channels$xmin' and 'channels$xmax' can be manually adjusted to ]0,1[ so as to be used as 'probs' argument to quantile to allow quantile normalization during object extraction (objectExtract) afterwards.

Value

an object of class 'IFC_param'.


Object Resizing

Description

Resizes mat to new dimensions.

Usage

objectResize(
  mat,
  size = c(0, 0),
  add_noise = TRUE,
  random_seed = NULL,
  bg = 0,
  sd = 0
)

Arguments

mat

a numeric matrix.

size

a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(0,0) for no change.

add_noise

if TRUE adds normal noise when size is larger than mat dimensions using rnorm(), from Rcpp. Default is TRUE.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

bg

mean value of the background added if add_noise is TRUE. Default is 0.

sd

standard deviation of the background added if add_noise is TRUE. Default is 0.

Value

a resized matrix with padding background if desired size is larger than original mat dimensions.


Object Transformation

Description

Function to normalize, colorize and add background to images.

Usage

objectTransform(
  mat,
  msk,
  color,
  input_range,
  mode,
  type,
  add_noise = TRUE,
  random_seed = NULL,
  size = c(0, 0),
  bg_mean = 0,
  bg_sd = 0,
  full_range = FALSE,
  force_range = FALSE,
  gamma = 1
)

Arguments

mat

a finite numeric matrix.

msk

a finite numeric matrix (mask identifying abnormalities). If missing, the default no cleansing will be done.

color

a color.

input_range

a finite numeric vector of 2 values, sets the range of the input intensity values. Values outside this range are clipped. Default is [0,4095].

mode

color mode export. Either "rgb", "gray" or "raw".

type

image object type.

add_noise

whether to add normal noise to background or not. Default is TRUE.

random_seed

a list of elements to pass to set.seed or a single value, interpreted as an integer, or NULL to be used when 'add_noise' is set to TRUE. Default is NULL. Note that NA_integer_ or list(seed = NA_integer_) can be used to not call set.seed at all.

size

a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is c(0,0) for no change.

bg_mean

mean value of the background added if 'add_noise' is TRUE. Default is 0.

bg_sd

standard deviation of the background added if 'add_noise' is TRUE. Default is 0.

full_range

only apply when 'mode' is not "raw", if 'full_range' is TRUE, then 'input_range' will be set to [0,4095] and 'gamma' forced to 1. Default is FALSE.

force_range

bool, only apply when 'mode' is not "raw", if 'force_range' is TRUE, then 'input_range' will be adjusted to object range in [-4095,+inf] and 'gamma' forced to 1. Default is FALSE.
Note that this parameter takes the precedence over 'input_range' and 'full_range'.

gamma

correction. Default is 1, for no correction.

Details

When 'add_noise' is FALSE and attr(msk, "removal") is "masked" or "MC", background will be automatically set to minimal pixel value.

Value

the matrix transformed according to input parameters


Object File Export

Description

Exports images to various types.

Usage

objectWrite(x, type, ...)

Arguments

x

a numeric matrix.

type

image type. Supported values are: "bmp", "jpeg", "png", and "tiff".

...

other arguments to be passed.


R/IDEAS Color Palette Mapping

Description

Maps colors between IDEAS and R.

Usage

paletteIFC(
  x = c("", "palette", "palette_R", "to_light", "to_dark")[1],
  col = "White"
)

Arguments

x

either "", "palette","palette_R", to_light, to_dark. Default is "".

col

a compatible color to transform to color or lightModeColor. Default is "White".
if 'x' == to_light, function will convert 'col' to lightModeColor.
if 'x' == to_dark, function will convert 'col' to color.
if 'col' is not found or 'x' is anything else then a data.frame of compatible colors is returned.

Value

IFC palette of available colors.


Lattice Histogram Panel Contructor

Description

Helper to create histogram panel

Usage

pan_hist(
  x,
  type,
  br,
  normalize,
  fill,
  lwd,
  lty,
  col,
  alpha,
  ylim,
  bin,
  border,
  include.lowest = TRUE,
  right = TRUE
)

Source

derived from lattice from Deepayan Sarkar


Lattice Key Panel Contructor

Description

Helper to add key to panel

Usage

pan_key(key, corner = c(0, 0.98), x = corner[1], y = corner[2])

Source

derived from lattice from Deepayan Sarkar


Histogram Smooth Constructor

Description

Helper to smooth histogram

Usage

pan_smooth(
  x,
  type,
  br,
  normalize,
  fill,
  lwd,
  lty,
  col,
  alpha,
  ylim,
  bin,
  border,
  include.lowest = TRUE,
  right = TRUE,
  factor = 0
)

Source

derived from lattice from Deepayan Sarkar


FCS Name Parser

Description

Separates names and alt-names from FCS features names.

Usage

parseFCSname(x)

Arguments

x

a character vector of FCS features names.

Details

when created FCS features names are formatted as 'PnN < PnS >'. The current function allows the separation between PnN and PnS.

Value

a 2 columns data.frame of names (PnN) and alt-names (PnS).


Parse Transformation Information

Description

Helper to parse transformation parameter.

Usage

parseTrans(string)

Arguments

string

character string describing transformation used and its parameters, if any.

Details

-If string is "P" no transformation will be applied.
-If string is of length 1 and coercible to a numeric, smoothLinLog will be applied with 'hyper' parameter set with as.numeric(string) value.
-Otherwise, string will be split with "|", 1st element will be considered as function to call and all other elements will be passed to this function after being coerced to numeric in the order they are provided with the exception of 1st one; if coercion results in NA, the argument will be skipped.

Value

a list with 3 members:
-what, the transformation function,
-args, he parameters to pass to this function (with the exception of the 1st one),
-trans, the transformation instruction coerced to character.


Plot and Stats Computation for IFC Graph

Description

Computes plot and stats from a IFC graph

Usage

plotGraph(
  obj,
  graph,
  draw = FALSE,
  stats_print = draw,
  color_mode = c("white", "black")[1],
  add_key = "panel",
  precision = c("light", "full")[1],
  trunc_labels = 38,
  trans = "asinh",
  bin,
  viewport = "ideas",
  backend = "lattice",
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

graph

a graph from 'obj' or a list that can be coerced by buildGraph.

draw

whether to draw plot or not. Default is FALSE.

stats_print

whether to print stats or not. Default is given by 'draw' argument.

color_mode

whether to extract colors from 'obj' in white or black mode. Default is "white".

add_key

whether to draw a "global" key under title or in the first "panel" or "both". Default is "panel".
Accepted values are either: FALSE, "panel", "global", "both" or c("panel", "global").
Note that it only applies when display is seen as overlaying populations.

precision

when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light".
-"light", the default, will only display points of same coordinates that are among the other layers.
-"full" will display all the layers.

trunc_labels

maximum number of characters to display for labels. Default is 38.

trans

the name of a transformation function for density graphs. If missing the default, the BasePop[[1]]$densitytrans, if any, will be retrieved, otherwise "asinh" will be used.

bin

number of bin used for histogram / density. Default is missing.

viewport

either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas".
-"ideas" will use same limits as the one defined in ideas.
-"data" will use data to define limits.
-"max" will use data and regions drawn to define limits.

backend

backend used for drawing. Allowed are "lattice", "base", "raster", "raster-edge", "raster-hybrid". Default is "lattice".
-"lattice" is the original one used in IFC using lattice,
-"base" will produce the plot using base,
-"raster" uses "base" for plotting but 2D graphs points will be produced as rasterImage.
This has the main advantage of being super fast allowing for plotting a huge amount of points while generating smaller objects (in bytes). However, plot quality is impacted with "raster" method and resizing can lead to unpleasant looking. -"raster-edge" is the same as "raster" except that points outside of limits will be drawn onto the edge.
-"raster-hybrid" uses "raster" for drawing on top of a first "raster-edge" pass to produce an hybrid display.

...

other arguments to be passed.

Value

it invisibly returns a list whose members are:
-stats, a table of statistics computed for the graph, if 'stats_print' was TRUE,
-input, a list with input parameters.


‘IFC_plot' Conversion to ’base' Plot

Description

Helper to convert ‘IFC_plot' to ’base' plot.

Usage

plot_base(obj)

Arguments

obj

an object of class 'IFC_plot' as created by plotGraph.


‘IFC_plot' Conversion to ’lattice' Plot

Description

Helper to convert ‘IFC_plot' to ’lattice' plot.

Usage

plot_lattice(obj)

Arguments

obj

an object of class 'IFC_plot' as created by plotGraph.


‘IFC_plot' Conversion to ’raster' Plot

Description

Helper to convert ‘IFC_plot' to ’raster' plot.

Usage

plot_raster(obj, pntsonedge = FALSE)

Arguments

obj

an object of class 'IFC_plot' as created by plotGraph.

pntsonedge

whether points outside of plotting region should be bounded on the edge. Default is FALSE to clip points. NA can be used to produce hybrid display, with plot being drawn with 'pntsonedge' = FALSE on top of plot with 'pntsonedge' = TRUE.


'IFC_plot' Statistics Extraction

Description

Helper to extract 'IFC_plot' statistics.

Usage

plot_stats(obj)

Arguments

obj

an object of class 'IFC_plot' as created by plotGraph.


Shortcut for Batch Images or Masks Extraction

Description

Function to shortcut extraction, normalization and eventually colorization of images or masks to various format.

Usage

polyExtractTo(
  ...,
  objects,
  offsets,
  display_progress = TRUE,
  image_type = "img",
  export = "matrix",
  mode = "raw"
)

Arguments

...

arguments to be passed to objectExtract with the exception of 'ifd' and 'bypass'(=TRUE).
/!\ If not any of 'fileName', 'info' and 'param' can be found in '...' then attr(offsets, "fileName_image") will be used as 'fileName' input parameter to pass to objectParam.

objects

integer vector, IDEAS objects ids numbers to use. This argument is not mandatory, if missing, the default, all objects will be used.

offsets

object of class 'IFC_offset'. This argument is not mandatory but it may allow to save time for repeated image export on same file.
If 'offsets' are not provided, extra arguments can also be passed with '...' to getOffsets.

display_progress

whether to display a progress bar. Default is TRUE.

image_type

(subsetOffsets argument) type of desired object offsets. Default is "img". Allowed are "img" or "msk".

export

(objectParam argument) format mode export. Either "file", "matrix", "base64". Default is "matrix".

mode

(objectParam argument) color mode export. Either "raw", "rgb", "gray". Default is "raw".

Details

If 'param' is provided in '...', 'param$export'<-'export' and 'param$mode'<-'mode' only will be overwritten.

Value

A list (for every extracted objects) of list (for every exported channels) depending on 'param$export' parameter:
-"matrix", a matrix when 'param$mode' is set to "raw" or "gray" OR an array when 'param$mode' is "rgb",
-"base64", a data-uri string,
-"file", an invisible file path corresponding to the location of exported file(s).

Note

Arguments of objectExtract will be deduced from input arguments.


IFC_pops Computation

Description

Function used to compute 'IFC_pops' object
It requires pops, regions and features.

Usage

popsCompute(
  pops,
  regions,
  features,
  pnt_in_poly_algorithm = 1,
  pnt_in_poly_epsilon = 1e-12,
  display_progress = TRUE,
  title_progress = "",
  ...
)

Arguments

pops

list of populations that will be coerced by buildPopulation.

regions

an object of class 'IFC_regions', list of regions.

features

an object of class 'IFC_features', data.frame of features.

pnt_in_poly_algorithm

algorithm used to determine if object belongs to a polygon region or not. Default is 1.
Note that for the moment only 1(Trigonometry) is available.

pnt_in_poly_epsilon

epsilon to determine if object belongs to a polygon region or not. It only applies when algorithm is 1. Default is 1e-12.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

...

other arguments to be passed.

Value

an object of class 'IFC_pops'.

Source

For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools


Copy Populations from One File to Another File

Description

Copies populations from a DAF file into a copy of another DAF file. Only creates new file with copied population.

Usage

popsCopy(
  from,
  into,
  write_to,
  pops,
  use_regex = FALSE,
  overwrite = FALSE,
  append_name = TRUE,
  offset = 0,
  endianness = .Platform$endian,
  verbose = FALSE,
  ...
)

Arguments

from

path to file to copy populations from.

into

path to file that will be used as a template to copy population into. Caution, it is mandatory that 'into' contains 'from' starting at 'offset'.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'into'
-%p: with first parent directory of 'into'
-%e: with extension of 'into' (without leading .)
-%s: with shortname from 'into' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that it has to be a .daf.

pops

regular expression or vector of desired populations present in 'from'.
If missing, the default, all populations found will be copied.
If given but not found, a warning will be sent.

use_regex

whether to use regex to pick up population into 'from'. Default is FALSE.

overwrite

whether to overwrite existing file or not. Default is FALSE. Note that if TRUE, it will overwrite exported file if path of 'into' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

append_name

whether to append_name basename(from) to exported populations. Default is TRUE.

offset

Object number of 1st object of 'from' in 'into'. Default is 0.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

...

Other arguments to be passed.

Details

Populations are exported as tagged populations.

Value

a new file is created containing exported populations.
It invisibly returns full path of exported file.


IFC_pops Affiliation Finder

Description

Helper that extracts populations dependencies/affiliations.

Usage

popsGetAffiliation(pops, operators = c("And", "Or", "Not", "(", ")"))

Arguments

pops

list of populations


IFC_pops Levels Dependency Determination

Description

Helper that extract population levels.

Usage

popsGetLevels(pops)

Arguments

pops

list of populations.


IFC_pops Object Numbers

Description

Retrieves objects ids belonging to a population.

Usage

popsGetObjectsIds(obj, pop = "")

Arguments

obj

an 'IFC_data' object extracted with features extracted.

pop

a population name from 'obj'. Default is "". If left as is or not found an error is thrown displaying all available population in 'obj'.

Value

An integer vector is returned

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  obj <- popsGetObjectsIds(obj = daf, pop = names(daf$pops)[length(daf$pops)])
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

IFC_pops Sibling Population Identification

Description

Gives names of graphical pops's siblings in a 'IFC_data' object.

Usage

popsGetSiblings(obj, pops)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

pops

graphical populations names to get siblings of.

Value

names of population siblings.


IFC_pops Sibling Population from Same Base Identification

Description

Gives names of graphical pops's siblings in a 'IFC_data' object. Siblings are built from a same population but different regions drawn on axes of same feature(s) with same transformation(s) applied if any.

Usage

popsGetSiblings1(obj, pops)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

pops

graphical populations names to get siblings of.

Value

names of population siblings.


IFC_pops Sibling Population from Same Region Identification

Description

Gives names of graphical pops's siblings in a 'IFC_data' object. Siblings are built from different populations but a same region drawn on axes of same feature(s) with same transformation(s) applied if any.

Usage

popsGetSiblings2(obj, pops)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

pops

graphical populations names to get siblings of.

Value

names of population siblings.


IFC_pops Network Display

Description

Builds and displays populations network.

Usage

popsNetwork(
  obj,
  hierarchical = TRUE,
  color_mode = "white",
  highlight = NULL,
  seed = NULL,
  direction = "LR",
  weighted = TRUE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

hierarchical

whether to display network using a hierarchical layout or not. Default is TRUE.

color_mode

Whether to extract colors from 'obj' in "white" or "black" mode. Default is "white".

highlight

population to permanently highlight. If found in 'obj', this population will be displayed with its color. Default is NULL.

seed

If you provide a seed manually, the layout will be the same every time. Default is NULL.

direction

The direction of the hierarchical layout. Default is 'LR'.
The available options are: 'UD', 'DU', 'LR', 'RL'. To simplify: up-down, down-up, left-right, right-left.

weighted

whether to scale population's node size according to count. Default is TRUE.

...

other argument to be passed.

Value

a visNetwork object.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  daf <- ExtractFromDAF(fileName = file_daf)
  popsNetwork(obj = daf)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

IFC_pops Population Level Ordering

Description

Helper that sort populations so that populations that depend from other are placed after.

Usage

popsOrderNodes(pops)

Arguments

pops

list of populations.


Populations Renaming

Description

Renames populations in an 'IFC_data' object

Usage

popsRename(
  obj,
  old_names = character(),
  new_names = character(),
  loops = 10L,
  verbose = TRUE,
  ...
)

Arguments

obj

an 'IFC_data'.

old_names

character vector of name(s) of population(s) to rename inside 'obj'. Default is character().

new_names

character vector of desired new population(s) name(s). Default is character().

loops

a positive integer specifying the maximum number of recursive loops before raising an error. Default is 10L.

verbose

whether to show a final message about the renaming. Default is TRUE.

...

other arguments to be passed.

Value

an object of class 'IFC_data'.


Graph Retrieval from Graphical IFC_pops

Description

Retrieves the graph a graphical population originate from

Usage

popsRetrieveGraph(obj, pops, vis2D = "density", all_siblings = FALSE)

Arguments

obj

an 'IFC_data' object extracted by ExtractFromDAF(extract_features = TRUE) or ExtractFromXIF(extract_features = TRUE).

pops

names of graphical populations present in 'obj'. Note that they should be siblings.

vis2D

when original graph is not an histogram, whether to display it as "scatter" or "density". Default is "density".

all_siblings

whether to add all 'pop' siblings in the graph. Default is FALSE.

Value

a list of parameters needed to build an IFC graph.


IFC_pops Checker for Object Membership to Populations

Description

Helper that will be used by popsCompute to determine which objects are within populations or not.

Usage

popsWithin(
  pops,
  regions,
  features,
  pnt_in_poly_algorithm = 1,
  pnt_in_poly_epsilon = 1e-12,
  display_progress = TRUE,
  title_progress = "",
  ...
)

Arguments

pops

list of populations.

regions

list of regions.

features

dataframe of features.

pnt_in_poly_algorithm

algorithm used to determine if object belongs to a polygon region or not. Default is 1.
Note that for the moment only 1(Trigonometry) is available.

pnt_in_poly_epsilon

epsilon to determine if object belongs to a polygon region or not. It only applies when algorithm is 1. Default is 1e-12.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

...

other arguments to be passed.

Source

For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools


Power of Two

Description

Raise values to power of two

Usage

pow2(x)

Name Protection

Description

Helper to protect population/region name.

Usage

protectn(name)

Arguments

name

population/region names


Pseudo Seed

Description

Creates seed from a string

Usage

pseudo_seed(x)

Arguments

x

a string.

Value

an integer.


Random Name Generator

Description

Generates random name

Usage

random_name(
  n = 10,
  ALPHA = LETTERS,
  alpha = letters,
  num = 0L:9L,
  special = c("#", "@", "?", "!", "&", "%", "$"),
  forbidden = character()
)

Arguments

n

number of characters of the desired return name. Default is 10.

ALPHA

upper case letters. Default is LETTERS.

alpha

lower case letters. Default is letters.

num

integer to use. Default is 0:9

special

characters. Default is c("#", "@", "?", "!", "&", "%", "$").

forbidden

forbidden character vector. Default is character().

Details

'forbidden' should not encompass all possible returned value otherwise the function will never end.

Value

a character string.


Fast 2D plot

Description

Creates fast 2D plots with Rcpp

Usage

rasterplot(
  x,
  y = NULL,
  pch = ".",
  size = 7,
  alpha = 255,
  col = "black",
  rgba = NULL,
  force = FALSE,
  draw = TRUE,
  new = is.null(bg_),
  interpolate = FALSE,
  width = 512,
  height = 512,
  pntsonedge = FALSE,
  blur_size = 9,
  blur_sd = 3,
  bg_ = NULL,
  bg_map = TRUE,
  ...
)

Arguments

x, y

the x and y coordinates for the plot. If 'y' is NULL, it will be same as 'x'. x and y should have same length.

pch

a vector of plotting symbols. Default is "." (resulting in a 1-pixel dot). Allowed are 0 to 20 and ".". It will be repeated along 'x'. With the exception of ".", NA resulting its coercion to integer(s) from the conversion will be omitted (i.e. points won't be displayed, but their x-y coordinates will account for xlim, ylim range computation when not provided through ...). Everything else (coercible to integer) will result in a dot (a 1-pixel pixel).

size

an integer vector giving the size(s) of the 'pch'. Default is 7. It will be repeated along 'x'.

alpha

a [0,255] integer. Default is 255.

col

a vector of desired colors of the symbols that will be passed by grDevices::col2rgb('x', alpha = TRUE). Default is "black". If number of colors equals number of points every point will be assigned this color. Otherwise, if color is of length 1 for a single combination of size / pch, all points with this combination will be assigned this color. Finally, if there is only one combination of size / pch and color not equals 1 nor the total number of points, then, colors will be used as a gradient for density (in such case 'blur_size' and 'blur_sd' will be taken in consideration) This only applies when 'force' is FALSE.

rgba

a 4 rows color matrix, with rows being Red, Green, Blue and Alpha and number of columns identical to number of points.
/!\ When provided this argument will take precedence over 'col' and 'alpha'.

force

whether to force scatter instead of density when multiple 'col' are provided

draw

whether to draw to plot (when TRUE), or to image only (when FALSE). Default is TRUE.

new

whether a new plot should be created, only applies when 'draw' is TRUE. Default is is.null(bg_). If FALSE, the current plot will be used to draw points.

interpolate

whether to use linear interpolation, only applies when 'draw' is TRUE. Default is FALSE.

width

the desired width of the raster Default is 512. It only applies when draw is FALSE.

height

the desired height of the raster Default is 512. It only applies when draw is FALSE.

pntsonedge

whether points outside of plotting region should be bounded on the edge. Default is FALSE to clip points.

blur_size

(for density) an integer controlling the size of the blurring gaussian kernel. Default is 9.

blur_sd

(for density) a double controlling the sd of the blurring gaussian kernel. Default is 3.

bg_

an 'rasterplot' object as returned by rasterplot() that will be used to add points to. Default is NULL. If provided it will have to be compatible with current drawing size or 'width' and 'height' when 'draw' is FALSE.

bg_map

whether to use 'bg_' when provided to compute points coordinates. Default is TRUE. This allows to get same "user" to "pixel" coordinates conversion as the one used to create 'bg_'.

...

other arguments to pass to graphics::plot(). For example, providing xlim and/or ylim will controls if point will be shown or not

Details

some examples:
set.seed(2)
n_points = 1e7; n_clusters = 5
x = c(t(sapply(1:5, FUN = function(i) rnorm(n_points / n_clusters, mean = sample(-2:2, size = 1), sd = 1/sample(1:10, 1)))))
y = c(t(sapply(1:5, FUN = function(i) rnorm(n_points / n_clusters, mean = sample(-2:2, size = 1), sd = 1/sample(1:10, 1)))))
# plot points
rasterplot(x = x, y = y, col = "black")
# generate img
rasterplot(x = x, y = y, col = "black", draw = FALSE)
# plot multiple shapes
rasterplot(x = x, y = y, pch = c(3,5,9,10,2))
# plot multiple shapes + colors
bg_ = rasterplot(x = x, y = y, pch = c(3,5,9,10,2), col = c("plum", "green", "indianred", "blue", "black"))
# addition of new points to an already drawn background, it a kind of points(...)
rasterplot(x = x[1:1e5], y = y[1:1e5], col = "black", bg_ = bg_, bg_map = TRUE)
# plot 1 shape + multiple colors
rasterplot(x = x, y = y, pch = ".", col = c("plum", "green", "indianred", "blue", "black"), force = TRUE)
# density
rasterplot(x = x, y = y, pch = 20, size = 7, draw = TRUE, col = colorRampPalette(c("blue", "green", "red"))(100))
# density with limits
rasterplot(x = x, y = y, draw = TRUE, xlim = c(0, 1.5), pntsonedge = FALSE, col = colorRampPalette(c("blue", "green", "red"))(100))
# density with limits + computation on drawn points only
rasterplot(x = x, y = y, draw = TRUE, xlim = c(0, 1.5), pntsonedge = TRUE, col = colorRampPalette(c("blue", "green", "red"))(100))
# using rgba
col = c("plum", "green", "indianred", "blue", "black")
rgba = col2rgb(col, alpha = TRUE)
rgba = t(apply(rgba, 1, FUN = function(x) rep(x, length.out = n_points)))
rasterplot(x = x, y = y, pch = ".", rgba = rgba, draw = TRUE)

Value

an [0, 255] integer array of (height, width, 4) of class 'rasterplot'


FCS File Parser

Description

Parse data from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCS(
  fileName,
  options = list(header = list(start = list(at = 0, n = 6), space = list(at = 6, n =
    4), text_beg = list(at = 10, n = 8), text_end = list(at = 18, n = 8), data_beg =
    list(at = 26, n = 8), data_end = list(at = 34, n = 8)), apply_scale = TRUE, dataset =
    1, force_header = FALSE, text_only = FALSE, text_check = FALSE, text_empty = FALSE,
    text_trim = "none"),
  display_progress = TRUE,
  ...
)

Arguments

fileName

path to file.

options

list of options used to parse FCS file. It should contain (otherwise, it will be filled with the default values listed below):
- header, a list whose members define the "at" offset from header$start$at and the "n" number of bytes to extract:
– start: where to start reading current FCS dataset. Default is list(at = 0, n = 6),
– space: where to retrieve space. Default is list(at = 6, n = 4),
– text_beg: where to retrieve file text segment beginning. Default is list(at = 10, n = 8),
– text_end: where to retrieve file text segment end. Default is list(at = 18, n = 8),
– data_beg: where to retrieve file data segment beginning. Default is list(at = 26, n = 8),
– data_end: where to retrieve file data segment end. Default is list(at = 34, n = 8),
- apply_scale, whether to apply data scaling. It only applies when fcs file is stored as DATATYPE "I". Default is TRUE.
- dataset, (coerced to) an ordered vector of unique indices of desired dataset(s) to extract. Default is 1 to extract only the first dataset, whereas NULL allows to extract all available datasets.
- force_header, whether to force the use of header to determine the position of data segment. Default is FALSE, for using positions found in "$BEGINDATA" and "$ENDDATA" keywords.
- text_only, whether to only extract text segment. Default is FALSE.
- text_check, whether to check text segment is compliant with FCS specifications. Default is FALSE.
- text_empty, whether to allow empty values when parsing text segment. Default is FALSE.
- text_trim, remove whitespace in keywords names. Default is "none". Allowed are "both", "left", "right" and "none".

display_progress

whether to display a progress bar. Default is TRUE.

...

other arguments to be passed.

Details

'options' may be tweaked according to file type, instrument and software used to generate it.
Default 'options' should allow to read most files.
'options' members with the exception of 'header' may be passed thanks to '...'.

Value

a list whose elements are lists for each dataset stored within the file.
each sub-list contains:
- header, list of header information corresponding to 'options'
- delimiter, unique character used to separate keyword-value pairs
- text, list of keywords values,
- data, data.frame of values.

Source

Data File Standard for Flow Cytometry, version FCS 3.1 from Spidlen J. et al. available at doi: 10.1002/cyto.a.20825.


FCS Data Parser

Description

Helper to parse data segment from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCSdata(
  fileName,
  text,
  start = 0,
  end = 0,
  scale = TRUE,
  display_progress = TRUE,
  ...
)

Arguments

fileName

path to file.

text

a named list of keywords values.

start

offset of text start. Default is 0.

end

offset of text end. Default is 0.

scale

whether to apply data scaling. It only applies when fcs file is stored as DATATYPE "I". Default is TRUE.

display_progress

whether to display a progress bar. Default is TRUE.

...

other arguments to be passed.


FCS Dataset Parser

Description

Helper to parse dataset from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCSdataset(fileName, options, display_progress = TRUE, ...)

Arguments

fileName

path to file.

options

list of options used to parse FCS file. It should contain (otherwise, it will be filled with the default values listed below):
- header, a list whose members define the "at" offset from header$start$at and the "n" number of bytes to extract:
– start: where to start reading current FCS dataset. Default is list(at = 0, n = 6),
– space: where to retrieve space. Default is list(at = 6, n = 4),
– text_beg: where to retrieve file text segment beginning. Default is list(at = 10, n = 8),
– text_end: where to retrieve file text segment end. Default is list(at = 18, n = 8),
– data_beg: where to retrieve file data segment beginning. Default is list(at = 26, n = 8),
– data_end: where to retrieve file data segment end. Default is list(at = 34, n = 8),
- apply_scale, whether to apply data scaling. It only applies when fcs file is stored as DATATYPE "I". Default is TRUE.
- dataset, (coerced to) an ordered vector of unique indices of desired dataset(s) to extract. Default is 1 to extract only the first dataset, whereas NULL allows to extract all available datasets.
- force_header, whether to force the use of header to determine the position of data segment. Default is FALSE, for using positions found in "$BEGINDATA" and "$ENDDATA" keywords.
- text_only, whether to only extract text segment. Default is FALSE.
- text_check, whether to check if text segment is compliant with FCS specifications. Default is FALSE.
- text_empty, whether to allow empty values when parsing text segment. Default is FALSE.
- text_trim, remove whitespace in keywords names. Default is "none". Allowed are "both", "left", "right" and "none".

display_progress

whether to display a progress bar. Default is TRUE.

...

other arguments to be passed.

Details

'options' may be tweaked according to file type, instrument and software used to generate it.
Default 'options' should allow to read most files.
'options' members with the exception of 'header' may be passed thanks to '...'.

Value

a list containing:
- options, list of 'options' used
- header, list of header information corresponding to 'options'
- delimiter, unique character used to separate keyword-value pairs
- text, list of keywords values,
- data, data.frame of values.


FCS Delimiter Reader

Description

Helper to extract delimiter from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCSdelimiter(fileName, at = 58, version = 3, encoding = "UTF-8", ...)

Arguments

fileName

path to file.

at

offset of delimiter. Default is 58.

version

version to check keywords compliance against. Default is 3.0.

encoding

name of the encoding for raw to character conversion. Default is "UTF-8".

...

other arguments to be passed.


FCS Header Parser

Description

Helper to parse header segment from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCSheader(fileName, header, encoding = "UTF-8", ...)

Arguments

fileName

path to file.

header

a list whose members define the "at" offset from header$start$at and the "n" number of bytes to extract:
- start: where to start reading current FCS dataset. Default is list(at = 0, n = 6),
- space: where to retrieve space. Default is list(at = 6, n = 4),
- text_beg: where to retrieve file text segment beginning. Default is list(at = 10, n = 8),
- text_end: where to retrieve file text segment end. Default is list(at = 18, n = 8),
- data_beg: where to retrieve file data segment beginning. Default is list(at = 26, n = 8),
- data_end: where to retrieve file data segment end. Default is list(at = 34, n = 8).

encoding

name of the encoding for raw to character conversion. Default is "UTF-8".

...

other arguments to be passed.


FCS Text Parser

Description

Helper to parse text segment from Flow Cytometry Standard (FCS) compliant files.

Usage

readFCStext(
  fileName,
  delimiter,
  start = 0,
  end = 0,
  encoding = "UTF-8",
  empty = FALSE,
  trim = "none",
  ...
)

Arguments

fileName

path to file.

delimiter

delimiter used to separate keyword-value pairs. /!\ NOTE that files with 0x00 'delimiter' can _NOT_ be parsed.

start

offset of text start. Default is 0.

end

offset of text end. Default is 0.

encoding

name of the encoding for raw to character conversion. Default is "UTF-8".

empty

whether to allow empty values when parsing text segment. Default is FALSE.

trim

remove whitespace in keywords names. Default is "none". Allowed are "both", "left", "right" and "none".

...

other arguments to be passed.


GatingML File Reader

Description

Extracts GatingML from file.

Usage

readGatingML(fileName, ...)

Arguments

fileName

path to file. It should be a .xml file.

...

other arguments to be passed.

Details

reading GatingML files is in development and partly implemented. For the moment, only files generated with IFC package can be read.

Value

A named list of class 'IFC_gating', whose members are:
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined.


Gating Strategy File Reader

Description

Extracts Gating Strategy from files.

Usage

readGatingStrategy(fileName, ...)

Arguments

fileName

path to file. It should be a .ast, .cif, .daf, .ist, .rif or .xml file.

...

other arguments to be passed.

Value

A named list of class 'IFC_gating', whose members are:
-spillover, a list of spillover matrices found,
-graphs, a list of graphical elements found,
-pops, a list describing populations found,
-regions, a list describing how regions are defined.


IFC Files Generic Reader

Description

Reads IFC data from IFC files no matter if they are FCS, DAF, RIF or CIF.

Usage

readIFC(fileName, ...)

Arguments

fileName

path to file.

...

arguments to pass to ExtractFromDAF or ExtractFromXIF or ExtractFromFCS.

Details

If input 'fileName' is a DAF file ExtractFromDAF will be used to read the file.
If it is a CIF or RIF file readIFC will use ExtractFromXIF.
Finally, if 'fileName' is not a DAF, nor a CIF, nor a RIF file readIFC will use ExtractFromFCS.

Value

an object of class 'IFC_data'.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a rif file, but you can also read daf or cif
  file_rif <- system.file("extdata", "example.rif", package = "IFCdata")
  rif <- readIFC(fileName = file_rif)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

IFC_features_def Redefinition

Description

Helper modify features_def according to masks or images redefinition.

Usage

redefine_features_def(
  features_def,
  masks,
  images,
  to_match_feat = NULL,
  to_replace_feat = NULL,
  ...
)

Arguments

features_def

an 'IFC_features_def' object, or a list containing features definition. Default is missing.

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

to_match_feat

a string with a features_def name to use for matching 'features_def' names. Default is NULL

to_replace_feat

a string of features_def name to use for replacing 'features_def' names. Default is NULL

...

Other arguments to be passed.

Value

a list whose members are:
-features_def, an 'IFC_features_def' object, or a list containing features definition
-masks, an 'IFC_masks' object or a data.frame containing masks definition and name.
-images, a data.frame containing images definition.


IFC_features_def Feature Redefinition

Description

Helper to rename a feature within IFC_features_def.

Usage

redefine_features_def_feat(
  features_def,
  to_match_feat = NULL,
  to_replace_feat = NULL,
  force_default = FALSE,
  ...
)

Arguments

features_def

an 'IFC_features_def' object or a list containing features definition. Default is missing.

to_match_feat

a string with a features_def name to use for matching 'features_def' names. Default is NULL

to_replace_feat

a string of features_def name to use for replacing 'features_def' names. Default is NULL

force_default

whether to force default names for features (except the one defined by 'to_replace_feat'). This removes custom names and replaces them with default values. Default is FALSE.

...

Other arguments to be passed.

Value

an 'IFC_features_def' object, or a list containing features definition


IFC_features_def Mask or Image Redefinition

Description

Helper to modify features_def according to masks or images redefinition.

Usage

redefine_features_def_msk_img(
  features_def,
  masks,
  images,
  force_default = FALSE,
  ...
)

Arguments

features_def

an 'IFC_features_def' object, or a list containing features definition. Default is missing.

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

force_default

whether to force default names for masks and features. This removes custom names and replaces them with default values. Default is FALSE.

...

Other arguments to be passed.

Value

a list whose members are:
-features_def, an 'IFC_features_def' object, or a list containing features definition
-masks, an 'IFC_masks' object or a data.frame containing masks definition and name.
-images, a data.frame containing images definition.


IFC_masks Redefinition

Description

Helper to modify features_def according to masks or images redefinition.

Usage

redefine_masks(
  masks,
  images,
  new_images_names = images$name,
  to_match_mask = NULL,
  to_replace_mask = NULL,
  ...
)

Arguments

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

new_images_names

a vector of image name to use for replacing 'images' names. Default is images$name

to_match_mask

a string with a mask name to use for matching 'masks' names. Default is NULL

to_replace_mask

a string of mask name to use for replacing 'masks' names. Default is NULL

...

Other arguments to be passed.

Value

a list whose members are: -masks, an 'IFC_masks' object or data.frame containing masks definition and name. -images, a data.frame containing images definition.


IFC_masks Image Redefinition

Description

Helper to rename images within masks definition.

Usage

redefine_masks_image(masks, images, new_images_names = images$name, ...)

Arguments

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

new_images_names

a vector of image name to use for replacing 'images' names. Default is images$name

...

Other arguments to be passed.

Value

a list whose members are: -masks, an 'IFC_masks' object or data.frame containing masks definition and name. -images, a data.frame containing images definition.


IFC_masks Mask Redefinition

Description

Helper to rename a mask within IFC_masks.

Usage

redefine_masks_mask(
  masks,
  images,
  to_match_mask = NULL,
  to_replace_mask = NULL,
  ...
)

Arguments

masks

an 'IFC_masks' object or a data.frame containing masks definition and name. Default is missing.

images

a data.frame containing images definition. Default is missing.

to_match_mask

a string with a mask name to use for matching 'masks' names. Default is NULL

to_replace_mask

a string of mask name to use for replacing 'masks' names. Default is NULL

...

Other arguments to be passed.

Value

a vector of masks definition or names depending on definition.


IFC_data Redefinition

Description

Helper to modify images, masks, features, pops, graphs in a 'IFC_data' object when features_def is changed.

Usage

redefine_obj(obj, new_feat_def, ...)

Arguments

obj

an 'IFC_data' object. Default is missing.

new_feat_def

a list with new definitions from redefine_features_def() or redefine_features_def_msk_img().

...

Other arguments to be passed.

Value

an 'IFC_data' object.


Change Graphs Layout

Description

Reconstructs 'IFC_graphs' object layout.

Usage

relayout(
  graphs,
  size = 320,
  splitterdistance = 120,
  stats = TRUE,
  byrow = FALSE,
  times = 4,
  layout = NULL
)

Arguments

graphs

an 'IFC_graphs' object extracted with features extracted.

size

Integer, graphs' sizes. Default is 320.

splitterdistance

Integer. Default is 120.

stats

Logical. Whether to show stats or not. Default is TRUE.

byrow

Logical. Whether to layout graphs by row or not. Default is FALSE.

times

Integer. Max number of graphs by row/column (depending on 'byrow'). Default is 4.

layout

Integer matrix. Desired layout. Default is NULL. When NULL, the default, graphs will be relayout using 'times' and 'byrow' parameters. Otherwise, layout will be used to determine the position of the graphs (NA value can be used for empty place). Note that when not NULL layout should contain all indices of graphs only once.

Value

an 'IFC_graphs' object


File Extension Removal

Description

Removes file extension from file path

Usage

remove_ext(x)

Arguments

x

a file path

Details

file extension will be removed


Reverse String

Description

Reverses string.

Usage

rev_string(x)

Arguments

x

a character vector.


Progress Bar Updater

Description

Updates a progress bar.

Usage

setPB(pb, value = NULL, title = NULL, label = NULL)

Arguments

pb

an object of class 'IFC_progress' containing a progress bar of class 'txtProgressBar', 'winProgressBar' or 'Progress'.

value

new value for the progress bar.

title, label

character strings, giving the 'title'(='message' for shiny progress bar) and the 'label'(='detail' for shiny progress bar).


Smooth Asinh Transformation

Description

Transforms values in asinh

Usage

smoothAsinh(x, hyper = 1000)

Smooth LinLog Transformation

Description

Transforms values in lin-log

Usage

smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))

Arguments

x

A numeric vector.

hyper

value where transition between Lin/Log is applied.

base

base of Log scale.

lin_comp

value that is used to smooth transition between Lin/Log. Default is log(base).

Value

the smoothLinLog transformation of the input.


Special Character Replacement

Description

Helper to replace special character.

Usage

specialr(
  string = "",
  replacement = "_",
  specials = "[\\|\\/|\\:|\\*|\\?|\\\"|'|\\<|\\>|\\|]"
)

Arguments

string

string where specials will be replaced if found.

replacement

string replacement. Default is "_".

specials

Default is '[\|\/|\:|\*|\?|\"|\'|\<|\>|\|]'.


IFC_features_def Definition Splitting

Description

Helper to split a features definitions within IFC_features_def.

Usage

split_feat(
  features_def,
  all_names = names(features_def),
  alt_names = NULL,
  m_names = sprintf("M%02i", 1:12),
  i_names = sprintf("Ch%02i", 1:12),
  comb_operators = c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT"),
  extr_operators = c("true", "false", "True", "False"),
  split = "|",
  force = FALSE
)

Arguments

features_def

an 'IFC_features_def' object or a list containing features definition. Default is missing.

all_names

the names of all allowed names.

alt_names

vector of same length as 'all_names' to use for substitution. It can be used to speed up the process.

m_names

names of masks.

i_names

names of images.

comb_operators

operators used for combined features. Default is c("+", "-", "*", "/", "(", ")", "ABS", "COS", "SIN", "SQR", "SQRT").

extr_operators

operators used for non combined features. Default is c("true", "false", "True", "False"). Those will be added to 'm_names', 'i_names' and all possible features names (as given by the getFromNamespace("featureIFC", "IFC")()).

split

string used for splitting. Default is "|".

force

whether to force splitting even if 'split' is detected.

Value

an 'IFC_features_def' object, or a list containing features definition


File Path Decomposition

Description

Helper that will split file name into chunks

Usage

splitf(file = NULL)

Arguments

file

path to file

Value

a named vector with chunks of 'file'
dir: full path directory of 'file'
parent: first parent directory of 'file'
ext: 'file' extension without leading dot
short: 'file' with no extension nor dir
input: 'file' path as it was provided.


String Decomposition with Operators

Description

Helper that will split definition into chunks of names and operators.

Usage

splitn(
  definition,
  all_names,
  alt_names,
  operators = c("And", "Or", "Not", "(", ")"),
  split = "|",
  scalar = FALSE,
  dsplit = FALSE
)

Arguments

definition

definition to be split

all_names

the names of all allowed names.

alt_names

vector of same length as 'all_names' to use for substitution. It can be used to speed up the process.

operators

operators used. Default is c("And", "Or", "Not", "(", ")").

split

string used for splitting. Default is "|".

scalar

whether to allow presence of scalar or not. Default is FALSE.

dsplit

whether to allow presence of duplicated occurrences of 'split' or not. Default is FALSE.


String Decomposition with Placeholders

Description

Helper aiming to detect placeholder pattern

Usage

splitp(write_to = "%d/%s_fromR.%e")

Arguments

write_to

string. Default is "%d/%s_fromR.%e"

Details

-%s: shortname (i.e. basename without extension)
-%p: first parent directory
-%d: full path directory
-%e: file extension
-%o: object id
-%c: channel


IFC_offset Subsetting

Description

Subsets 'IFC_offset'

Usage

subsetOffsets(offsets, objects, image_type = c("img", "msk"))

Arguments

offsets

object of class 'IFC_offset' to subset.

objects

integer vector, IDEAS objects ids numbers to extract.

image_type

image_type of desired offsets. Default is c("img", "msk"). Allowed are "img" and/or "msk".

Value

a class 'IFC_offset' integer vector or empty integer() if objects are outside of offsets.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  ## use a cif file
  file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
  ## extract offsets
  offsets <- getOffsets(fileName = file_cif)
  ## subset offsets of the 4 first "img" objects
  sub_offs <- subsetOffsets(offsets = offsets, objects = 0:3, image_type = "img")
  ## show subsetted offsets' structure
  str(sub_offs)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

RIF/CIF File Subsetting

Description

Subsets RIF or CIF files.

Usage

subsetXIF(
  fileName,
  write_to,
  objects,
  offsets,
  fast = TRUE,
  extract_features = FALSE,
  endianness = .Platform$endian,
  verbose = FALSE,
  verbosity = 1,
  overwrite = FALSE,
  display_progress = TRUE,
  add_tracking = TRUE,
  ...
)

Arguments

fileName

path of file to subset. It has to be a '.rif' or '.cif' file.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'fileName'
-%p: with first parent directory of 'fileName'
-%e: with extension of 'fileName' (without leading .)
-%s: with shortname from 'fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. It has to be the same as 'fileName', i.e. .cif or .rif.

objects

integer vector, IDEAS objects ids numbers to use. If missing, the default, all objects will be used.

offsets

object of class ‘IFC_offset'. If missing, the default, offsets will be extracted from ’fileName'.
This param is not mandatory but it may allow to save time for repeated XIF export on same file.

fast

whether to fast extract 'objects' or not. Default is TRUE. Meaning that 'objects' will be extracted expecting that 'objects' are stored in ascending order.
Note that a warning will be sent if an 'object' is found at an unexpected order. In such a case you may need to rerun function with 'fast' = FALSE. If set to FALSE, all raw object_ids will be scanned from 'fileName' to ensure extraction of desired 'objects'.
IMPORTANT: whatever this argument is, features are extracted assuming an ascending order of storage in file.

extract_features

whether to try to extract features. Default is FALSE. IMPORTANT: it is not clear if how features are stored and which objects they rely to when input file is already a merge or a subset. For this reason it should be carefully checked.

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

verbosity

quantity of information displayed when verbose is TRUE; 1: normal, 2: rich. Default is 1.

overwrite

whether to overwrite file or not. Default is FALSE.
Note that if TRUE, it will overwrite exported file if path of 'fileName' and deduced from 'write_to' arguments are different. Otherwise, you will get an error saying that overwriting source file is not allowed.
Note also that an original file, i.e. generated by IDEAS(R) or INSPIRE(R), will never be overwritten. Otherwise, you will get an error saying that overwriting original file is not allowed.

display_progress

whether to display a progress bar. Default is TRUE.

add_tracking

whether to register files' paths and objects' ids in the exported file. Default is TRUE.

...

other arguments to be passed.

Details

when 'extract_features' is set TRUE, only features stored in binary format will be extracted if found.
If the input 'fileName' is a merged of several files then features will be extracted from these files.
If these files can't be found, Warning(s) will be thrown and input 'fileName' will be extracted without features values.

Value

It invisibly returns full path of exported file.


Channel Swap

Description

Swaps Channels within 'IFC_data' object

Usage

swap_channel(obj, chan1, chan2, BF = TRUE, MODE = 1)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

chan1, chan2

an integer index of channel. 'chan1' and 'chan2' should be different.

BF

should 'from' channel be considered as brightfield. Default is TRUE.

MODE

collection mode (as retrieved by getInfo) determining the range. Default is 1.

Details

'BF' and 'MODE' will be used only if 'chan1' or 'chan2' is not found in 'obj'.
/!\ NOTE: In case of conflict between resulting names, 'chan2' will be preferred, maximizing number of features with 'chan2'.

Value

a list, intended to be passed to 'new_feat_def' argument of getFromNamespace("redefine_obj", "IFC") whose members are:
-features_def, an 'IFC_features_def' object, or a list containing features definition
-masks, an 'IFC_masks' object or a data.frame containing masks definition and name.
-images, a data.frame containing images definition.


Channel Switch

Description

Switches Channel in 'IFC_data' object

Usage

switch_channel(obj, from, to, BF = TRUE, MODE = 1)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

from, to

an integer index of channel. 'from' and 'to' should be different.

BF

should 'from' channel be considered as brightfield. Default is TRUE.

MODE

collection mode (as retrieved by getInfo) determining the range. Default is 1.

Details

'BF' and 'MODE' will be used only if 'to' is not found in 'obj'.
If switching channel results in duplicated features definition, e.g. "Intensity_M01_Ch01" and "Intensity_M04_Ch04" exists in 'from' and user called switch_channel(obj, 4, 1). So, "Intensity_M01_Ch01" will become "Intensity_M01_Ch01" (the same) and, "Intensity_M04_Ch04" will become "Intensity_M01_Ch01". Meaning that resulting "Intensity_M01_Ch01" can originate from either "Intensity_M01_Ch01" or "Intensity_M04_Ch04". In such case duplicates will be collected in 'dup' member of attr(, "map").
/!\ Note also that 'initial' member of attr(, "map") will always be the one of 'from', i.e. "Intensity_M01_Ch01" will be mapped with "Intensity_M04_Ch04" .

Value

a list, intended to be passed to 'new_feat_def' argument of getFromNamespace("redefine_obj", "IFC") whose members are:
-features_def, an 'IFC_features_def' object, or a list containing features definition
-masks, an 'IFC_masks' object or a data.frame containing masks definition and name.
-images, a data.frame containing images definition.


RIF/CIF Image Order Test

Description

Tests order of IFD within RIF and XIF file

Usage

testXIF(fileName)

Arguments

fileName

path of file.

Value

an integer
-1: not a XIF file
0: non regular XIF file, i.e. no mask found after 1st Image itself after 1st IFD
+1: regular XIF file, i.e. a mask is found after 1st Image itself after 1st IFD.


Text to Image Conversion

Description

Converts string to matrix of 0 and 1.

Usage

texttomatrix(text = NULL)

Arguments

text

a character string.

Details

at symbol @ is a special character used for scale


IFC_features Raw Conversion

Description

Helper to convert features ('IFC_features' object) to raw vector.

Usage

toBIN_features(
  features,
  w_con = raw(),
  endianness = .Platform$endian,
  verbose = FALSE,
  display_progress = TRUE,
  title_progress = "",
  ...
)

Arguments

features

an 'IFC_features' object.

w_con

a connection opened for writing. Default is raw().

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display message about current action. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

...

other arguments to be passed.

Value

a raw vector of features binaries.


IFC_images Raw Conversion

Description

Helper to convert images ('IFC_images' object) to raw vector.

Usage

toBIN_images(
  images,
  w_con = raw(),
  endianness = .Platform$endian,
  verbose = FALSE,
  display_progress = TRUE,
  title_progress = "",
  ...
)

Arguments

images

an 'IFC_images' object.

w_con

a connection opened for writing. Default is raw().

endianness

The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

verbose

whether to display message about current action. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

...

other arguments to be passed.

Value

an raw vector of images binaries.


First Letter Only Capitalization

Description

Helper to capitalize the first letter of strings and leave the rest to lower case

Usage

toCapFirstOnly(text)

Arguments

text

a string


Ellipsoid Polygon Constructor

Description

Helper to transform gate boundaries to ellipsoid polygon.

Usage

toEllipse(gate, theta = 2 * pi, npoints = 100)

Arguments

gate

list containing x and y ellipse boundaries coordinates.

theta

rotation angle of the ellipse. Default is 2*pi. It should not be modified since ellipse gate are axis-aligned.

npoints

number of polygon vertices desired.


Boolean Population GatingML Conversion to XML2

Description

Helper to convert boolean population to XML nodes in GatingML files.

Usage

toXML2_boolpop_gs(obj, pop, already = character())

Arguments

obj

an 'IFC_data' object.

pop

a member of 'IFC_pops' object.

already

already attributed names. Default is character().

Value

a list of xml_node.


IFC_features XML Conversion

Description

Helper to convert features ('IFC_features' object) to XML nodes.

Usage

toXML2_features(
  features,
  verbose = FALSE,
  display_progress = TRUE,
  title_progress = ""
)

Arguments

features

an 'IFC_features' object.

verbose

whether to display message about current action. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

Value

a xml_node.


IFC_features_def XML Conversion

Description

Helper to convert features definition ('IFC_features_def' object) to XML nodes.

Usage

toXML2_features_def(features_def, verbose = verbose)

Arguments

features_def

an `IFC_features_def` object.

verbose

whether to display message about current action. Default is FALSE.

Value

a XML::xmlNode.


Graphical Population GatingML Conversion to XML2

Description

Helper to convert pops and regions to XML nodes in GatingML files.

Usage

toXML2_graphpop_gs(pop, reg, verbose = FALSE)

Arguments

pop

a member of 'IFC_pops' object.

reg

a member of 'IFC_regions' object.

verbose

whether to display message about current action. Default is FALSE.

Value

a xml_node.


IFC_graphs XML Conversion

Description

Helper to convert graphs ('IFC_graphs' object) to XML nodes.

Usage

toXML2_graphs(graphs, verbose = FALSE)

Arguments

graphs

an 'IFC_graphs' object.

verbose

whether to display message about current action. Default is FALSE.

Value

a xml_node.


IFC_graphs GatingML Conversion

Description

Helper to convert graphs ('IFC_graphs' object) to XML nodes in GatingML files.

Usage

toXML2_graphs_gs(graphs)

Arguments

graphs

an 'IFC_graphs' object.

Value

a xml_node.


IFC_images XML Conversion

Description

Helper to convert images ('IFC_images' object) to XML nodes.

Usage

toXML2_images(
  images,
  verbose = FALSE,
  display_progress = TRUE,
  title_progress = ""
)

Arguments

images

an 'IFC_images' object.

verbose

whether to display message about current action. Default is FALSE.

title_progress

character string, giving the title of the progress bar. Default is "".

Value

a xml_node.


IFC_masks XML Conversion

Description

Helper to convert masks ('IFC_masks' object) to XML nodes.

Usage

toXML2_masks(masks, verbose = FALSE)

Arguments

masks

an 'IFC_masks' object.

verbose

whether to display message about current action. Default is FALSE.

Value

a xml_node.


IFC_pops XML Conversion

Description

Helper to convert populations ('IFC_pops' object) to XML nodes.

Usage

toXML2_pops(
  pops,
  verbose = FALSE,
  display_progress = TRUE,
  title_progress = "",
  ...
)

Arguments

pops

an 'IFC_pops' object.

verbose

whether to display message about current action. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

title_progress

character string, giving the title of the progress bar. Default is "".

...

other arguments to be passed.

Value

a xml_node.


IFC_regions XML Conversion

Description

Helper to convert regions ('IFC_regions' object) to XML nodes.

Usage

toXML2_regions(regions, verbose = FALSE)

Arguments

regions

an 'IFC_regions' object.

verbose

whether to display message about current action. Default is FALSE.

Value

a xml_node.


Spillover GatingML Conversion

Description

Helper to convert spillover to XML nodes in GatingML files.

Usage

toXML2_spillover_gs(spillover, name)

Arguments

spillover

a spillover matrix. It has to have colnames and rownames.

name

the name to use to identify the node.

Value

a xml_node.


IFC_stats XML Conversion

Description

Helper to convert stats ('IFC_stats' object) to XML nodes.

Usage

toXML2_stats(stats, verbose = FALSE)

Arguments

stats

an 'IFC_stats' object.

verbose

whether to display message about current action. Default is FALSE.

Value

a xml_node.


XML Node to List Conversion

Description

Helper to convert xml node to R list.

Usage

to_list_node(x, max = 5)

Arguments

x

A document, node, or node set.

max

maximum number of recurrence into subnodes. Default is 5.

Details

it acts as_list but value returned is different, with attributes expanded to sublists rather than recovered as attributes


List to XML Node Conversion

Description

Helper to convert R list to xml node (character representation).

Usage

to_xml_list(x, name, kids, indent = "  ", escape = "\n")

Arguments

x

a list to convert

name

name of the node to create

kids

a list containing children xml nodes elements (each elements should come from to_xml_list)

indent

indent used for kids when provided. Default is " ".

escape

escape used for kids when provided. Default is "\n".

Details

it acts as_list but value returned is different, with attributes expanded to sublists rather than recovered as attributes


String Truncation

Description

Truncates character strings

Usage

trunc_string(x, n = 22)

Arguments

x

a string

n

desired length

Details

x will be truncated according to 'n' parameter. If x is longer than n '...' are appended.


Report File Creation

Description

Checks if report files can be created.

Usage

tryReportFileCreation(fileName, write_to, overwrite = FALSE)

Arguments

fileName

default fileName path.

write_to

pattern used to export file(s). Placeholders, like c("%d/%s_fromR.pdf", "%d/%s_fromR.csv"), will be substituted:
-%d: with full path directory of 'fileName'
-%p: with first parent directory of 'fileName'
-%e: with extension of 'fileName' (without leading .)
-%s: with shortname from 'fileName' (i.e. basename without extension).
Exported file(s) extension(s) will be deduced from this pattern. Note that has to be a .pdf and/or .csv.

overwrite

whether to overwrite file or not. Default is FALSE. Note that if TRUE, it will overwrite file. In addition a warning message will be sent.

Value

a list with path(s) to pdf and csv file and overwritten status


Histogram Type Constructor

Description

Helper to construct histogram

Usage

type_constr(x, br, type, include.lowest = TRUE, right = TRUE, plot = FALSE)

Source

derived from lattice from Deepayan Sarkar


IFC_data Default Naming

Description

Helper to reset masks and features names to their default values in a 'IFC_data' object.

Usage

usedefault_obj(obj, ...)

Arguments

obj

an 'IFC_data' object. Default is missing.

...

Other arguments to be passed.

Value

an 'IFC_data' object.


Histogram Val Constructor

Description

Helper to construct histogram

Usage

val_constr(x, h, type)

Source

derived from lattice from Deepayan Sarkar


Boolean Expression Validation

Description

Helper to check if a boolean vector is valid.

Usage

validate_bool(x = "", all_names = "")

Arguments

x

a string vector representing the boolean expression to be validated.

all_names

a character vector of scalars which are allowed to be part of the the boolean expression.

Value

x is returned if no exception is raised during validation process.


Input Identification

Description

Helper that identifies input arguments thanks to their IFC classes even if they are not or mis named.

Usage

whoami(
  entries = as.list(match.call()),
  search = list(info = "IFC_info", param = "IFC_param", offsets = "IFC_offset"),
  reinit = TRUE
)

Arguments

entries

arguments from the function whoami is called. /!\ whoami MUST be called explicitly this way: whoami(entries = as.list(match.call())).

search

a non duplicated named list of classes to search for entries.

reinit

whether to reinitialize arguments to their default values in called environment. Default is TRUE.

Details

if two argument of the same 'search' class are found an error will be thrown. 'fileName' will be searched every time.
-at first, as an argument (named or not) of the class designated in 'search' to be the "fileName",
-otherwise, as an argument (named or not) of class 'fileName',
-otherwise, as a named argument of name "fileName" that was not found using 'search',
-and finally, if still not found as the first not named argument not found in 'search' of type string.

Value

a list whose members are 'fileName': value of fileName if provided as a named argument in entries and all classes defined in 'search'


With Seed Evaluation

Description

Evaluates expression with a seed and resets to initial seed state on exit

Usage

with_seed(
  expr,
  seed = NA_integer_,
  kind = NULL,
  normal.kind = NULL,
  sample.kind = NULL
)

Arguments

expr

expression to evaluate.

seed

a single value, interpreted as an integer, or NULL, with the exception that NA can be provided to prevent passing 'seed' argument. Default is NA_integer_.

kind

character or NULL. If kind is a character string, set R's RNG to the kind desired. Use "default" to return to the R default.

normal.kind

character string or NULL. If it is a character string, set the method of Normal generation. Use "default" to return to the R default. NULL makes no change.

sample.kind

character string or NULL. If it is a character string, set the method of discrete uniform generation (used in sample, for instance). Use "default" to return to the R default. NULL makes no change. Only applies on R version >= 3.6.0.

Details

see ‘Details’, from set.seed, with the exception of 'seed'. Using seed = NA_integer_, NOTHING will be passed to set.seed nor RNGkind and NOTHING will be restored once done. Otherwise, set.seed will be used and once done RNGkind will be restored and ".Random.seed" from globalenv set back to its initial value (included removed if it did not exist).


Gating Strategy File Writer

Description

Writes GatingML from an 'IFC_data' object to a xml file

Usage

writeGatingStrategy(
  obj,
  write_to,
  overwrite = FALSE,
  display_progress = TRUE,
  verbose = FALSE,
  ...
)

Arguments

obj

an 'IFC_data' object extracted with features extracted.

write_to

pattern used to export file. Placeholders, like "%d/%s_fromR.%e", will be substituted:
-%d: with full path directory of 'obj$fileName'
-%p: with first parent directory of 'obj$fileName'
-%e: with extension of 'obj$fileName' (without leading .)
-%s: with shortname from 'obj$fileName' (i.e. basename without extension).
Exported file extension will be deduced from this pattern. Note that it has to be a .xml.

overwrite

whether to overwrite file or not. Default is FALSE.

display_progress

whether to display a progress bar. Default is TRUE.

verbose

whether to display information (use for debugging purpose). Default is FALSE.

...

other arguments to be passed.

Details

Partial implementation of ISAC's Gating-ML 2.0 data exchange standard for gating description. See Josef Spidlen et al. Cytometry A 87 683-687 (2015). doi: 10.1002/cyto.a.22690
GatingML is partly implemented because:
-Tagged population are not part of GatingML gates
-IDEAS/INSPIRE regions are different from the collection of gates listed in GatingML. Notably,
–only 1 or 2 dimensions gates will be used, –range gates and quadrant gates are absent from IDEAS/INSPIRE –ellipse gates exist in IDEAS/INSPIRE but are axis aligned and not rotated. -Transformation applied in IFC is not part of GatingML. Nonetheless, when possible additional information are provided in dedicated custom_info field.

Value

It invisibly returns full path of exported file.


IFC Files Generic Writer

Description

Writes IFC data to DAF and subsets or merges RIF/CIF Files.

Usage

writeIFC(fileName, ...)

Arguments

fileName

path to file.

...

arguments to pass to ExportToDAF, ExportToXIF, ExportToFCS, or data_to_DAF.

Details

If an ‘IFC_data' object is provided as ’fileName' or in '...' ExportToFCS or data_to_DAF will be used to export object. Otherwise, if 'fileName' is a DAF file ExportToDAF will be used to write file whereas if it is RIF or CIF file(s) writeIFC will use ExportToXIF.

Value

it invisible returns the path of exported file.

Examples

if(requireNamespace("IFCdata", quietly = TRUE)) {
  tmp <- tempdir(check = TRUE)
  ## use a daf file
  file_daf <- system.file("extdata", "example.daf", package = "IFCdata")
  ## create a tagged population named test with 1st object
  pop <- buildPopulation(name = "test", type = "T", obj = 0)
  writeIFC(file_daf, write_to = paste0(tmp, "\\test_write.daf"),
           overwrite = TRUE, pops = list(pop))
  ## use a rif file, but you can also use a cif
  file_rif <- system.file("extdata", "example.rif", package = "IFCdata")
  writeIFC(fileName = file_rif, write_to = paste0(tmp, "\\test_write.rif"), 
           overwrite = TRUE, objects = 0)
} else {
  message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
                  'https://gitdemont.github.io/IFCdata/',
                  'to install extra files required to run this example.'))
}

Image Field Directory Writer

Description

Writes Image Field Directory (IFD)

Usage

writeIFD(
  ifd,
  r_con,
  w_con,
  pos = 0,
  extra = NULL,
  endianness = .Platform$endian,
  last = FALSE,
  ...
)

Arguments

ifd

an ifd extracted by cpp_fastTAGS

r_con

a connection opened for reading

w_con

a connection opened for writing

pos

current position within 'w_con'. Default is 0.

extra

extra entries to add to 'ifd'. Default is NULL

endianness

the desired endian-ness ("big" or "little"). Default is .Platform$endian.
Endianness describes the bytes order of data stored within the files. This parameter may not be modified.

Value

the position within 'w_con' after 'IFD' and 'extra' content have been written


List to XML Conversion

Description

Helper to convert R list to xml node (character representation).

Usage

xml_new_node(name, attrs, .children, text, ...)

Arguments

name

name of the node to create.

attrs

a named list of name-value pairs to be used as attributes for the XML node.

.children

a list containing XML node elements or content.

text

the text content for the new XML node.

Value

an R object that points to the C-level structure instance.

mirror server hosted at Truenetwork, Russian Federation.