Mathematical operations in FCS file
0
0
Entering edit mode
@chandraswarnendu-22534
Last seen 22 months ago

I am trying to do the analysis of my fcs file by flowCore. In my analysis I have fl1 and fl3 data, but I want to create a new column consisting of the mathematical calculation ((fl1+fll3) /fl1) and name it df and then plot it as df in x-axis and fl1 in y-axis. Is there any function in flowCore package or in any other package, which can help me in doing this in my fcs file?

flowCore flow cytometry • 319 views
ADD COMMENT
1
Entering edit mode

use frappendcols

see https://github.com/RGLab/flowCore/issues/121 For your case, something like this

library(flowCore)
data(GvHD)
fr <- GvHD[[1]]
mat <- exprs(fr)
cols <- (mat[,"FL1-H"] + mat[,"FL3-H"])/mat[,"FL1-H"]
cols <- matrix(cols, dimnames = list(NULL, "df"))
fr1 <- fr_append_cols(fr, cols)
fr1
library(ggcyto)
p <- autoplot(fr1, "df", "FL1-H")
p
ADD REPLY
0
Entering edit mode

Thanks..... It is a great help.

ADD REPLY
0
Entering edit mode

I am trying to use a for loop to add the new column in all fcs files at the same time. my codes are

library(flowCore)
data(GvHD)
fs<-GvHD
for (i in 1:35) {
   fr <- fs[[i]]
   mat <- exprs(fr)
   cols <- (mat[,”FL1-H”] + mat[,”FL3-H”])/mat[,”FL1-H”]
   cols <- matrix(cols, dimnames = list(NULL, “df”))
   df.fr <- fr[fr1]
   fs[i]<-fr1
}

The error I am gating is: Error in abs(i) : non-numeric argument to mathematical function

Please help.

ADD REPLY
1
Entering edit mode

You cannot add a column to a flowFrame of a flowSet directly, because all flowFrames of the flowSet are sharing the exact same set of columns (Mike will correct me if I'm wrong). This does not explain the error, but it will improve your loop. You have to define clearly your result. If you want to get a flowSet at the end of the process, you will have to build a flowSet from the modified flowFrames. Mike may have a nice piece of code. If you want to get a set of modified FCS files, just write the modified flowFrame to disk using write.FCS. PS1: be careful with double quote PS2: try to improve your knowledge about R concerning vectors and lists PS3: I added some comments to Mike's code

# get one flowFrame
fr <- GvHD[[1]]
# extract the matrix of values to work with
mat <- exprs(fr)
# compute one new column aka marker
new.cols <- (mat[,"FL1-H"] + mat[,"FL3-H"])/mat[,"FL1-H"]
head(new.cols)
# convert this vector to a matrix and give a name to this column
new.cols <- matrix(new.cols, dimnames = list(NULL, "df"))
head(new.cols)
# add this columm at the end of the flowFrame
fr1 <- fr_append_cols(fr, cols)
enter code here
ADD REPLY

Login before adding your answer.

Traffic: 285 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6