FluidigmDataConversion: Correct orientation of data for model analysis.

Description Usage Arguments Examples

Description

Corrects data organization for model analysis. The genes are transferred along columns and samples are transferred along rows for further analysis.

Usage

1
FluidigmDataConversion(d, Cell = 2, Gene = 5, Value = 7)

Arguments

d
Cell
Gene
Value

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (d, Cell = 2, Gene = 5, Value = 7) 
{
    d1 <- as.data.frame(d[, c(Cell, Gene, Value)])
    for (i in 1:length(d1[, 3])) {
        if (d1[i, 3] == 999) 
            d1[i, 3] = NA
    }
    colnames(d1) <- c("c", "g", "v")
    CellNames <- na.omit(unique(d1[, 1]))
    GeneNames <- na.omit(unique(d1[, 2]))
    dat <- as.data.frame(matrix(nrow = length(CellNames), ncol = length(GeneNames)))
    colnames(dat) <- GeneNames
    rownames(dat) <- CellNames
    for (i in 1:length(CellNames)) {
        for (j in 1:length(GeneNames)) {
            dat[i, j] <- d1[which((as.character(d1$c) == as.character(CellNames[i])) & 
                (as.character(d1$g) == as.character(GeneNames[j]))), 
                3]
        }
    }
    dat <- cbind(CellNames, dat)
    colnames(dat) <- c("CellNames", GeneNames)
    write.csv(dat, "FluidigmDataConverted.csv", quote = FALSE, 
        row.names = FALSE)
    return(NULL)
  }

bvnlab/SCATTome documentation built on May 13, 2019, 9:05 a.m.