Title: | Tools for Imaging Flow Cytometry |
---|---|
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. |
Authors: | Yohann Demont [aut, cre], Gautier Stoll [ctb], Guido Kroemer [ldr], Jean-Pierre Marolleau [ldr], Loïc Garçon [ldr] |
Maintainer: | Yohann Demont <[email protected]> |
License: | GPL-3 |
Version: | 0.2.1.710 |
Built: | 2025-02-17 08:45:11 UTC |
Source: | https://github.com/gitdemont/ifc |
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.
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 valuessmoothLinLog
, 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
Maintainer: Yohann Demont <[email protected]>
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.
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, ... )
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, ... )
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. |
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, |
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 |
y |
feature for y-axis. Default is NULL.
When empty, |
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 |
type |
type of plot. Default is NULL to allow |
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 |
viewport |
Either "ideas", "data" or "max" defining limits used for the graph. Default is "ideas". |
precision |
when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light". |
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. |
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"
an lattice trellis object
Batch creates graphical an statistical report.
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, ... )
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, ... )
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. |
write_to |
pattern used to export file(s).
Placeholders, like c("%d/%s_fromR.pdf", "%d/%s_fromR.csv"), will be substituted: |
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". |
precision |
when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light". |
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". |
backend |
backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice". |
display_progress |
whether to display a progress bar. Default is TRUE. |
... |
other parameters to be passed. |
It invisibly returns full path of exported .pdf and/or .csv file(s).
Prepares XML node for ExportToBATCH
.
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 )
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 )
files |
path of files to batch. |
compensation |
path to compensation file. |
analysis |
path to analysis file. |
default_batch_dir |
directory where batches are stored. |
config_file |
path to IDEAS(R) config file. |
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. |
options |
A list of arguments to be passed. |
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'.
Helper to build a list to allow feature export.
buildFeature( name, type = c("single", "combined", "computed")[1], def = "Camera Line Number", val = NULL, ... )
buildFeature( name, type = c("single", "combined", "computed")[1], def = "Camera Line Number", val = NULL, ... )
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. |
... |
Other arguments to be passed. |
a list containing all feature information.
Helper to build a list to allow graph export.
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()), ... )
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()), ... )
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. |
axistickmarklabelsfontsize |
Integer. Axis tick font size. Default is 10. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28. |
graphtitlefontsize |
Integer. Axis title font size. Default is 12. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28. |
regionlabelsfontsize |
Integer. Axis region font size. Default is 10. Allowed are: 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28. |
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. |
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. |
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".
a list containing all graph information.
Helper to build a list to allow population export.
buildPopulation( name, type, base = "All", color, lightModeColor, style, region, fx, fy, definition, obj, ... )
buildPopulation( name, type, base = "All", color, lightModeColor, style, region, fx, fy, definition, obj, ... )
name |
name of the population. |
type |
type of population. Either "B", "C", "G" or "T" for Base, Combined, Graphical or Tagged, respectively. |
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 |
lightModeColor |
lightModeColor of the population. See |
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: |
... |
Other arguments to be passed. |
a list containing all population information.
Helper to build a list to allow region export.
buildRegion( type, label, cx, cy, color, lightcolor, ismarker = "false", doesnotoverride = "false", xlogrange, ylogrange, x, y, ... )
buildRegion( type, label, cx, cy, color, lightcolor, ismarker = "false", doesnotoverride = "false", xlogrange, ylogrange, x, y, ... )
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 |
lightcolor |
lightcolor of the region. See |
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. |
a list containing all region information.
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.
checksumIFC(fileName, ...)
checksumIFC(fileName, ...)
fileName |
path to file. |
... |
arguments to pass to |
if fileName is a DAF file, then CIF checksum is computed from images values found in DAF.
an integer corresponding to IFC file checksum.
Writes TIFF IFD (Image Field Directory).
img |
RawVector, an encoded image. It should contain 'dims', 'what' and 'comp' attributes. |
tags |
List, extra tags to be included to IFD. Expecting a list whose sub-elements are list containing: |
offset |
uint32_t, position of the IFD beginning. Default is |
endianness |
std::string, "little" or "big". |
rgb |
bool, whether to write channels as rgb. Default is |
last |
bool, whether IFD is the last one. Default is |
verbose |
bool, whether to display information (use for debugging purpose). Default is |
a RawVector
Adds features to an already existing 'IFC_data' object.
data_add_features(obj, features, ...)
data_add_features(obj, features, ...)
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 |
... |
Other arguments to be passed. |
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.
an IFC_data object with features added.
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.')) }
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.')) }
Adds graphs to an already existing 'IFC_data' object.
data_add_graphs(obj, graphs, adjust_graph = TRUE, ...)
data_add_graphs(obj, graphs, adjust_graph = TRUE, ...)
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 |
adjust_graph |
whether to try to adjust graph(s) when possible. Default is TRUE. |
... |
Other arguments to be passed. |
an IFC_data object with graphs added.
Adds populations to an already existing 'IFC_data' object.
data_add_pops( obj, pops, pnt_in_poly_algorithm = 1, pnt_in_poly_epsilon = 1e-12, display_progress = TRUE, ... )
data_add_pops( obj, pops, pnt_in_poly_algorithm = 1, pnt_in_poly_epsilon = 1e-12, display_progress = TRUE, ... )
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 |
pnt_in_poly_algorithm |
algorithm used to determine if object belongs to a polygon region or not. Default is 1. |
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. |
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.
an IFC_data object with pops added.
For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools
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.')) }
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.')) }
Adds regions to an already existing 'IFC_data' object.
data_add_regions(obj, regions, ...)
data_add_regions(obj, regions, ...)
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 |
... |
Other arguments to be passed. |
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.
an IFC_data object with regions added.
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.')) }
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.')) }
Removes regions from an already existing 'IFC_data' object.
data_rm_features(obj, features, list_only = TRUE, adjust_graph = TRUE, ...)
data_rm_features(obj, features, list_only = TRUE, adjust_graph = TRUE, ...)
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. |
... |
Other arguments to be passed. |
an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.
Removes graphs from an already existing 'IFC_data' object.
data_rm_graphs(obj, graphs, list_only = TRUE, adjust_graph = TRUE, ...)
data_rm_graphs(obj, graphs, list_only = TRUE, adjust_graph = TRUE, ...)
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. |
... |
Other arguments to be passed. |
an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.
Removes populations from an already existing 'IFC_data' object.
data_rm_pops(obj, pops, list_only = TRUE, adjust_graph = TRUE, ...)
data_rm_pops(obj, pops, list_only = TRUE, adjust_graph = TRUE, ...)
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. |
... |
Other arguments to be passed. |
an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.
Removes regions from an already existing 'IFC_data' object.
data_rm_regions(obj, regions, list_only = TRUE, adjust_graph = TRUE, ...)
data_rm_regions(obj, regions, list_only = TRUE, adjust_graph = TRUE, ...)
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. |
... |
Other arguments to be passed. |
an ‘IFC_data' object or a list of elements impacted by removal depending on ’list_only' parameter.
Writes an 'IFC_data' object to a daf file
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, ... )
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, ... )
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: |
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. |
binary |
whether to write object to file in binary mode or not. Default is TRUE. |
endianness |
The endian-ness ("big" or "little") of the target system for the file. Default is .Platform$endian. |
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 |
... |
other arguments to be passed. |
It invisibly returns full path of exported file.
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.')) }
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.')) }
Displays gallery of 'IFC_img' / 'IFC_msk' objects
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] )
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 to be passed to |
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. |
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 |
( |
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.
it invisibly returns a list whose members are:
-data, data for DT::datatable(),
-args, associated arguments to pass to DT::datatable().
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.')) }
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.')) }
Writes an XML file to batch files
ExportToBATCH(batch)
ExportToBATCH(batch)
batch |
list of batch nodes as created by |
It invisibly returns full path of xml batch file.
Writes a new DAF file based on another one and exports new region(s), pop(s), feature(s), graph(s) and / or mask(s).
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, ... )
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, ... )
fileName |
path of file to read data from. |
write_to |
pattern used to export file.
Placeholders, like "%d/%s_fromR.%e", will be substituted: |
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. |
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. |
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 |
... |
other arguments to be passed. |
It invisibly returns full path of exported file.
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.')) }
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.')) }
Writes an 'IFC_data' object to a Flow Cytometry Standard (FCS) file.
ExportToFCS( obj, write_to, overwrite = FALSE, delimiter = "/", cytometer = "Image Stream", ... )
ExportToFCS( obj, write_to, overwrite = FALSE, delimiter = "/", cytometer = "Image Stream", ... )
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: |
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. |
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. |
... |
other arguments to be passed. keyword-value pairs can be passed here. |
invisibly returns full path of exported file.
Exports gallery of 'IFC_img' / 'IFC_msk' objects
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 )
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 to be passed to |
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. |
base64_id |
whether to add id attribute to base64 exported object. Default is TRUE. |
base64_att |
attributes to add to base64 exported object. Default is "". |
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. |
scale |
a named list whose members are 'size', 'style', 'color', 'xoff', 'yoff'. Default is list() to draw no scale. Otherwise, |
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. |
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.
Depending on 'export':
-"matrix", a rgb array,
-"base64", a data-uri string,
-"file", an invisible vector of ids corresponding to the objects exported.
Exports IFC objects to numpy array [objects,height,width,channels]
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 )
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 to be passed to |
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 |
type of desired object offsets. Either |
size |
a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is |
force_width |
whether to use information in |
display_progress |
whether to display a progress bar. Default is |
python |
path to python. Default is |
dtype |
desired arrays data-type. Default is |
mode |
( |
export |
export format. Either |
write_to |
used when |
overwrite |
whether to overwrite file or not. Default is |
Please note that 'size'
parameter has to be supplied and could not be set to (0,) when 'object'
length is not equal to oneExportToNumpy
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.
Depending on 'export'
:
-"matrix"
, an array whose dimensions are [object, height, width, channel].
-"file"
, it invisibly returns path of ".npy"
exported file.
Arguments of objectExtract
will be deduced from ExportToNumpy
input arguments.
Generates report from 'IFC_data' object.
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, ... )
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, ... )
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. |
write_to |
pattern used to export file(s).
Placeholders, like c("%d/%s_fromR.pdf", "%d/%s_fromR.csv"), will be substituted: |
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". |
precision |
when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light". |
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". |
backend |
backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice". |
display_progress |
whether to display a progress bar. Default is TRUE. |
... |
other parameters to be passed. |
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.
It invisibly returns full path of exported .pdf and/or .csv file(s).
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.')) }
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.')) }
Subsets or merges RIF or CIF files.
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, ... )
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, ... )
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: |
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'. |
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. |
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. |
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. |
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. |
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.
It invisibly returns full path of exported file.
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.')) }
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.')) }
Extracts data from DAF Files.
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, ... )
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, ... )
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. |
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. |
pnt_in_poly_algorithm |
algorithm used to determine if object belongs to a polygon region or not. Default is 1. |
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. |
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.
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.
For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools
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.')) }
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.')) }
Extracts data from Flow Cytometry Standard (FCS) Files.
ExtractFromFCS(fileName, ...)
ExtractFromFCS(fileName, ...)
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'. |
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.
Data File Standard for Flow Cytometry, version FCS 3.2 from Spidlen J. et al. available at doi:10.1002/cyto.a.24225.
Extracts data from RIF or CIF Files.
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, ... )
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, ... )
fileName |
path to file. |
extract_features |
whether to extract features from file. Default is TRUE. |
extract_images |
whether to extract images information from file. Default is FALSE. |
extract_offsets |
whether to extract IFDs offsets from corresponding. Default is FALSE. |
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. |
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. |
recursive |
whether to recursively apply |
... |
Other arguments to be passed. |
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.
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.
For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools
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.')) }
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.')) }
Function to shortcut extraction, normalization and eventually colorization of images to base64 ! excludes mask.
ExtractImages_toBase64( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, base64_id, base64_att )
ExtractImages_toBase64( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, base64_id, base64_att )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
mode |
( |
write_to |
used to compute respectively exported file name. |
base64_id |
whether to add id attribute to base64 exported object. |
base64_att |
attributes to add to base64 exported object. |
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'
(="")
A list of base64 encoded images corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractImages_toBase64
input arguments.
Function to shortcut extraction, normalization and eventually colorization of images to file ! excludes mask.
ExtractImages_toFile( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, overwrite = FALSE )
ExtractImages_toFile( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, overwrite = FALSE )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
mode |
( |
write_to |
used to compute respectively exported file name. |
overwrite |
whether to overwrite file or not. Default is |
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"
.
It invisibly returns a list of exported file path of corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractImages_toFile
input arguments.
Function to shortcut extraction, normalization and eventually colorization of images to matrix ! excludes mask.
ExtractImages_toMatrix(..., objects, offsets, display_progress = TRUE)
ExtractImages_toMatrix(..., objects, offsets, display_progress = TRUE)
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
If 'param'
is provided in '...'
, 'param$export'<-"matrix"
only will be overwritten.
A list of matrices/arrays of images corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractImages_toMatrix
input arguments.
Function to shortcut extraction images to multichannel tiff ! excludes mask.
ExtractImages_toMulti( ..., objects, offsets, display_progress = TRUE, write_to, overwrite = FALSE )
ExtractImages_toMulti( ..., objects, offsets, display_progress = TRUE, write_to, overwrite = FALSE )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
write_to |
used to compute respectively exported file name. |
overwrite |
whether to overwrite file or not. Default is |
If 'param'
is provided in '...'
:
-'param$export'<-"multi"
, 'param$mode'<-"raw"
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 "multi"
.'write_to'
has to be provided if 'param'
can't be found in '...'
or if 'param$export'
was not "multi"
.
It invisibly returns a list of exported file path of corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractImages_toMulti
input arguments.
Function to shortcut extraction, normalization and eventually colorization of masks to base64 ! excludes image.
ExtractMasks_toBase64( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, base64_id, base64_att )
ExtractMasks_toBase64( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, base64_id, base64_att )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
mode |
( |
write_to |
used to compute respectively exported file name. |
base64_id |
whether to add id attribute to base64 exported object. |
base64_att |
attributes to add to base64 exported object. |
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'
(="")
A list of base64 encoded images corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractMasks_toBase64
input arguments.
Function to shortcut extraction, normalization and eventually colorization of masks to file ! excludes image.
ExtractMasks_toFile( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, overwrite = FALSE )
ExtractMasks_toFile( ..., objects, offsets, display_progress = TRUE, mode = c("rgb", "gray")[1], write_to, overwrite = FALSE )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
mode |
( |
write_to |
used to compute respectively exported file name. |
overwrite |
whether to overwrite file or not. Default is |
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"
.
It invisibly returns a list of exported file path of corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractMasks_toFile
input arguments.
Function to shortcut extraction, normalization and eventually colorization of masks to matrix ! excludes image.
ExtractMasks_toMatrix(..., objects, offsets, display_progress = TRUE)
ExtractMasks_toMatrix(..., objects, offsets, display_progress = TRUE)
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
If 'param'
is provided in '...'
, 'param$export'<-"matrix"
only will be overwritten.
A list of matrices/arrays of images corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractMasks_toMatrix
input arguments.
Function to shortcut extraction of masks to multichannel tiff ! excludes image.
ExtractMasks_toMulti( ..., objects, offsets, display_progress = TRUE, write_to, overwrite = FALSE )
ExtractMasks_toMulti( ..., objects, offsets, display_progress = TRUE, write_to, overwrite = FALSE )
... |
arguments to be passed to |
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. |
display_progress |
whether to display a progress bar. Default is TRUE. |
write_to |
used to compute respectively exported file name. |
overwrite |
whether to overwrite file or not. Default is |
If 'param'
is provided in '...'
:
-'param$export'<-"multi"
, 'param$mode'<-"raw"
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 "multi"
.'write_to'
has to be provided if 'param'
can't be found in '...'
or if 'param$export'
was not "multi"
.
It invisibly returns a list of exported file path of corresponding to objects extracted.
Arguments of objectExtract
will be deduced from ExtractMasks_toMulti
input arguments.
Generates unique non matching alternative names
gen_altnames( x, n = 10, forbidden = character(), random_seed = list(seed = 252, "Mersenne-Twister", "Inversion", "Rounding") )
gen_altnames( x, n = 10, forbidden = character(), random_seed = list(seed = 252, "Mersenne-Twister", "Inversion", "Rounding") )
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. |
'forbidden' should not encompass all possible returned value otherwise the function will never end.
a character vector.
Try to retrieve files whose processing failed during batch. This is a very beta version
getAborted(aborted, default_batch_dir, config_file)
getAborted(aborted, default_batch_dir, config_file)
aborted |
path to file containing aborted information. |
default_batch_dir |
directory where batches are stored. |
config_file |
path to IDEAS(R) config file. |
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.
Retrieves full tag value from IFDs (Image Field Directory) extracted by getIFD
.
getFullTag(IFD, which = 1, tag = "256", raw = FALSE)
getFullTag(IFD, which = 1, tag = "256", raw = FALSE)
IFD |
an object of class 'IFC_ifd_list' extracted by |
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. |
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.
the full value of the corresponding IFD tag.
TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html
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.
getIFD( fileName, offsets = "first", trunc_bytes = 12, force_trunc = FALSE, verbose = FALSE, verbosity = 1, display_progress = FALSE, bypass = FALSE, ... )
getIFD( fileName, offsets = "first", trunc_bytes = 12, force_trunc = FALSE, verbose = FALSE, verbosity = 1, display_progress = FALSE, bypass = FALSE, ... )
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. |
force_trunc |
whether to force truncation for all TAGS types. Default is FALSE. |
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. |
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
.
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
TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html
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.')) }
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.')) }
Retrieves rich information from RIF, CIF and DAF files.
getInfo( fileName, from = c("acquisition", "analysis")[2], verbose = FALSE, verbosity = 1, warn = TRUE, force_default = TRUE, cifdir = dirname(fileName), ntry = +Inf, ... )
getInfo( fileName, from = c("acquisition", "analysis")[2], verbose = FALSE, verbosity = 1, warn = TRUE, force_default = TRUE, cifdir = dirname(fileName), ntry = +Inf, ... )
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 |
... |
other arguments to be passed. |
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,
-Origin_rif, character vector of path of rif used to create cif, if input file was a cif,
-Merged_rif, character vector of path of files used to create rif, if input file was a merged,
-XIF_type, character definig XIF type,
-XIF_test, integer defining XIF type,
-checksum, integer corresponding to file checksum,
-fileName, path of fileName input,
-fileName_image, path of fileName_image.
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.')) }
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.')) }
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.
getOffsets(fileName, fast = TRUE, display_progress = TRUE, verbose = FALSE)
getOffsets(fileName, fast = TRUE, display_progress = TRUE, verbose = FALSE)
fileName |
path to file. |
fast |
whether to fast extract 'objects' or not. Default is TRUE. |
display_progress |
whether to display a progress bar. Default is TRUE. |
verbose |
whether to display information (use for debugging purpose). Default is FALSE. |
Offsets are byte positions of IFDs found within RIF or CIF file. For more details see TIFF specifications.
an integer vector of class 'IFC_offset' of IFDs offsets found in XIF file.
TIFF 6.0 specifications archived from web https://web.archive.org/web/20211209104854/https://www.adobe.io/open/standards/TIFF.html
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.')) }
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.')) }
Gets values back just to their original values before applying smoothLinLog.
inv_smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))
inv_smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))
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). |
the inverse smoothLinLog transformation of the input.
Removes abnormalities (clipped/debris) from image.
objectCleanse(mat, msk, add_noise = TRUE, random_seed = NULL, bg = 0, sd = 0)
objectCleanse(mat, msk, add_noise = TRUE, random_seed = NULL, bg = 0, sd = 0)
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. |
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].
This function is intended to display object extracted by objectExtract
.
objectDisplay( image, input_range = c(0, 4095), full_range = FALSE, force_range = FALSE, gamma = 1, color = "Green", dpi = 300 )
objectDisplay( image, input_range = c(0, 4095), full_range = FALSE, force_range = FALSE, gamma = 1, color = "Green", dpi = 300 )
image |
An object extracted by |
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 |
full_range |
if |
force_range |
if |
gamma |
|
color |
a color. Default is |
dpi |
display resolution. Default is |
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.
it invisibly returns NULL
Extracts / Decompress objects stored in RIF or CIF Files.
objectExtract(ifd, param, verbose = FALSE, bypass = FALSE, ...)
objectExtract(ifd, param, verbose = FALSE, bypass = FALSE, ...)
ifd |
list of sub elements of IFD data information extracted by |
param |
object of class 'IFC_param', containing extraction parameters defined by |
verbose |
whether to display information (use for debugging purpose). Default is |
bypass |
whether to bypass checks on |
... |
Arguments passed on to
|
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.
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).
-"multi"
, an invisible file path corresponding to the location of exported file(s).
'...'
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
.
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.
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.')) }
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.')) }
Defines 'IFC_object' object extraction parameters.
objectParam( ..., info, mode = c("rgb", "gray", "raw")[3], export = c("file", "matrix", "base64", "multi")[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 )
objectParam( ..., info, mode = c("rgb", "gray", "raw")[3], export = c("file", "matrix", "base64", "multi")[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 to be passed to |
info |
object of class 'IFC_info', rich information extracted by |
mode |
color mode export. Either |
export |
format mode export. Either |
write_to |
used when export is not |
base64_id |
whether to add id attribute to base64 exported object. Default is |
base64_att |
attributes to add to base64 exported object. Default is |
overwrite |
only apply when |
composite |
character vector of image composite. Default is |
selection |
physical channels to extract. |
size |
a length 2 integer vector of final dimensions of the image, height 1st and width 2nd. Default is |
force_width |
whether to use information in |
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 |
removal |
removal method: Either |
add_noise |
if |
full_range |
only apply when |
force_range |
only apply when |
spatial_correction |
only apply on RIF file, whether to apply spatial correction. Default is |
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.
an object of class 'IFC_param'.
Maps colors between IDEAS and R.
paletteIFC( x = c("", "palette", "palette_R", "to_light", "to_dark")[1], col = "White" )
paletteIFC( x = c("", "palette", "palette_R", "to_light", "to_dark")[1], col = "White" )
x |
either "", "palette","palette_R", to_light, to_dark. Default is "". |
col |
a compatible color to transform to color or lightModeColor. Default is "White". |
IFC palette of available colors.
Computes plot and stats from a IFC graph
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", ... )
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", ... )
obj |
an 'IFC_data' object extracted with features extracted. |
graph |
a graph from 'obj' or a list that can be coerced by |
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". |
precision |
when graphs is a 2D scatter with population overlay, this argument controls amount of information displayed. Default is "light". |
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". |
backend |
backend used for drawing. Allowed are "lattice", "base", "raster". Default is "lattice". |
... |
other arguments to be passed. |
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.
Function used to compute 'IFC_pops' object
It requires pops, regions and features.
popsCompute( pops, regions, features, pnt_in_poly_algorithm = 1, pnt_in_poly_epsilon = 1e-12, display_progress = TRUE, title_progress = "", ... )
popsCompute( pops, regions, features, pnt_in_poly_algorithm = 1, pnt_in_poly_epsilon = 1e-12, display_progress = TRUE, title_progress = "", ... )
pops |
list of populations that will be coerced by |
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. |
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. |
an object of class 'IFC_pops'.
For pnt_in_poly_algorithm, Trigonometry, is an adaptation of Jeremy VanDerWal's code https://github.com/jjvanderwal/SDMTools
Copies populations from a DAF file into a copy of another DAF file. Only creates new file with copied population.
popsCopy( from, into, write_to, pops, use_regex = FALSE, overwrite = FALSE, append_name = TRUE, offset = 0, endianness = .Platform$endian, verbose = FALSE, ... )
popsCopy( from, into, write_to, pops, use_regex = FALSE, overwrite = FALSE, append_name = TRUE, offset = 0, endianness = .Platform$endian, verbose = FALSE, ... )
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: |
pops |
regular expression or vector of desired populations present in 'from'. |
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. |
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. |
verbose |
whether to display information (use for debugging purpose). Default is FALSE. |
... |
Other arguments to be passed. |
Populations are exported as tagged populations.
a new file is created containing exported populations.
It invisibly returns full path of exported file.
Retrieves objects ids belonging to a population.
popsGetObjectsIds(obj, pop = "")
popsGetObjectsIds(obj, pop = "")
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'. |
An integer vector is returned
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.')) }
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.')) }
Builds and displays populations network.
popsNetwork( obj, hierarchical = TRUE, color_mode = "white", highlight = NULL, seed = NULL, direction = "LR", weighted = TRUE, ... )
popsNetwork( obj, hierarchical = TRUE, color_mode = "white", highlight = NULL, seed = NULL, direction = "LR", weighted = TRUE, ... )
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'. |
weighted |
whether to scale population's node size according to count. Default is TRUE. |
... |
other argument to be passed. |
a visNetwork object.
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.')) }
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.')) }
Renames populations in an 'IFC_data' object
popsRename( obj, old_names = character(), new_names = character(), loops = 10L, verbose = TRUE, ... )
popsRename( obj, old_names = character(), new_names = character(), loops = 10L, verbose = TRUE, ... )
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. |
an object of class 'IFC_data'.
Parse data from Flow Cytometry Standard (FCS) compliant files.
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, ... )
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, ... )
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): |
display_progress |
whether to display a progress bar. Default is TRUE. |
... |
other arguments to be passed. |
'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 '...'.
Experimental (as of v0.2.1.300), readFCS could handle FCS 3.2 files. However, it is important to note that R has no native support for 64bits unsigned integers which are defined in the FCS 3.2 standard.
So, those integers are extracted as double (8 bytes) and precision loss will happen for > 2^53 integers on 64bits platforms.
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.
Data File Standard for Flow Cytometry, version FCS 3.2 from Spidlen J. et al. available at doi:10.1002/cyto.a.24225.
Reads IFC data from IFC files no matter if they are FCS, DAF, RIF or CIF.
readIFC(fileName, ...)
readIFC(fileName, ...)
fileName |
path to file. |
... |
arguments to pass to |
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
.
an object of class 'IFC_data'.
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.')) }
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.')) }
Transforms values in lin-log
smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))
smoothLinLog(x, hyper = 1000, base = 10, lin_comp = log(base))
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). |
the smoothLinLog transformation of the input.
Subsets 'IFC_offset'
subsetOffsets(offsets, objects, image_type = c("img", "msk"))
subsetOffsets(offsets, objects, image_type = c("img", "msk"))
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". |
a class 'IFC_offset' integer vector or empty integer() if objects are outside of offsets.
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.')) }
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.')) }
Writes IFC data to DAF and subsets or merges RIF/CIF Files.
writeIFC(fileName, ...)
writeIFC(fileName, ...)
fileName |
path to file. |
... |
arguments to pass to |
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
.
it invisible returns the path of exported file.
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.')) }
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.')) }