Learn R Programming

imcExperiment data container

Containerizing IMC data into the SummarizedExperiment class, this container inherits packages from FlowSOM and diffcyt to compute clusters and test for differential abundance or state heterogeneity. Creating a flowSet is cumbersome, so we can stream-line into a summarized experiment into a quick and fast way to detect changes in cell populations.


 library(CATALYST)
 library(diffcyt)
 library(imcExperiment)
 data(imcdata)
 head(rownames(imcdata))
 imcData<-imcdata
    # for plot scatter to work need to set the rowData feature in a specific way.
    channel<-sapply(strsplit(rownames(imcData),"_"),function(x) x[3])
    channel[34:35]<-c("Ir1911","Ir1931")
    marker<-sapply(strsplit(rownames(imcData),"_"),function(x) x[2])
    rowData(imcData)<-DataFrame(channel_name=channel,marker_name=marker)
    rownames(imcData)<-marker
    plotScatter(imcData,rownames(imcData)[17:18],assay='counts')

  # convert to flowSet
  ## the warning has to do with duplicated Iridium channels.
   (fsimc <- sce2fcs(imcData, split_by = "ROIID"))
    ## now we have a flowSet.
   pData(fsimc)
   fsApply(fsimc,nrow)
   dim(exprs(fsimc[[1]]))
   exprs(fsimc[[1]])[1:5,1:5]
  ## set up the metadata files.
  head(marker_info)
   
   exper_info<-data.frame(group_id=colData(imcData)$Treatment[match(pData(fsimc)$name,
   colData(imcData)$ROIID)],
                           patient_id=colData(imcData)$Patient.Number[match(pData(fsimc)$name,
                           colData(imcData)$ROIID)],
                           sample_id=pData(fsimc)$name)
   
   ## create design
   design<-createDesignMatrix(
   exper_info,cols_design=c("group_id","patient_id"))
   
   ##set up contrast 
   contrast<-createContrast(c(0,1,0))
   nrow(contrast)==ncol(design)
   data.frame(parameters=colnames(design),contrast)
   
    ## flowSet to DiffCyt
    out_DA<-diffcyt(
      d_input=fsimc,
      experiment_info=exper_info,
      marker_info=marker_info,
      design=design,
      contrast=contrast,
      analysis_type = "DA",
      seed_clustering = 123
    )
   topTable(out_DA,format_vals = TRUE)
   
   out_DS<-diffcyt(
     d_input=fsimc,
     experiment_info=exper_info,
     marker_info=marker_info,
     design=design,
     contrast=contrast,
     analysis_type='DS',
     seed_clustering = 123,
     plot=FALSE)
   
      topTable(out_DS,format_vals = TRUE)

Copy Link

Version

Install

install.packages('imcExperiment')

Monthly Downloads

189

Version

0.99.0

License

MIT + file LICENSE

Maintainer

Anthony Colombo

Last Published

August 19th, 2021

Functions in imcExperiment (0.99.0)

percentilenormalize

given a matrix of intensity counts, perform min/max norm.
selectCases

subsets the imcExperiment to a case along with all slots for a selected multiple ROIs.
imcdata

imcdata
imcExperimentToHyperFrame

map to point pattern from imcExperiment class.
imcExperiment

Initializes a imcExperiment and performs some rudimentary checks. Many of the arguments CAN be NULL; determination of which is required is done at run-time. A imcExperiment must contain at least the expressions and spatial/coordinate assays.
getMorphology<-

re-assigns morphological features can be stored (matrix) rows are cells and columns are Area, etc.
imcExperiment-class

a summarized experiment of IMC runs, dimensions of the spatial and intensity data are regulated.#'
subsetCase

subsets the imcExperiment to a case along with all slots for a single ROI, using for distance analysis
getCoordinates

finds the spatial coords, getter.
.imcExperimentToPPP

map to point pattern from imcExperiment class.
data

data
getDistance<-

re-assigns the distance matrix (rows are cells)
getCoordinates<-

Sets the coordinate positions of each cell (matrix), columns are X,Y positions.
cellIntensity

finds the intensities getter.
.checkSpatialDimension

the rows are the panel names, the columns are the single cells,the column are the single cells to match the SCE designs (scRNA)
getNeighborhood

finds the neighborhood information.
getNetwork<-

re-assigns the network assignment (matrix)