Question: flowcore: z-Score normalization of flowSet (fsApply or normalize)
0
gravatar for BenAbflack
4.1 years ago by
BenAbflack0
Zurich/Switzerland
BenAbflack0 wrote:

Hey all,

​I am trying to normalise (some chosen) expression values of all flowFrames within a flowSet. They desired output would be again a flowSet. Unfortunately my understanding of defining functions in R is not sufficient to do so.

What I have tried so far was to use fsApply (flowcore) or normalize (flowcore) functions, however I think that both were unsuccesful because I wasnt able to define the normalization function correctly. For matrices, z-Score normalization is easily possible with the scale function, but I wasnt able to translate this into a working solution for flowSets.

Does anyone have more experience in defining function in R and has any idea how to solve this? See my naive and failed attempts below.

Thanks a lot and best wishes, Jerg


Try1 using fsApply:

scale_fun <- scale(x, center = TRUE, scale = TRUE)
fs_scaled <- fsApply(fs_initial, FUN = scale, center = T, scale = TRUE, 
                     simplify = T,
                     use.exprs = T) 
 


Try2 using normalization:

scale_fun <- normalization(parameters = scale_para,  

                           normalizationId = "zScore", 

                           normFunction = scale, 
                           arguments = list("x=data", "center=T", "scale=T"))

fs_norm  <- normalize(data = fs_initial, x = scale_fun)

ADD COMMENTlink modified 4.1 years ago by Jiang, Mike1.2k • written 4.1 years ago by BenAbflack0
Answer: flowcore: z-Score normalization of flowSet (fsApply or normalize)
2
gravatar for Jiang, Mike
4.1 years ago by
Jiang, Mike1.2k
(Private Address)
Jiang, Mike1.2k wrote:

Then you simply pass your chosen columns as argument to 'FUN'

fs_scaled <- fsApply(fs_initial, FUN = function(fr, channels){
                                      mat <- exprs(fr)[, channels, drop = FALSE]

                                      exprs(fr)[, channels] <- scale(mat)

                                      fr
                                      }, channels = c("FSC-H", "SSC-H")
                                                                    ) 
ADD COMMENTlink written 4.1 years ago by Jiang, Mike1.2k
Answer: flowcore: z-Score normalization of flowSet (fsApply or normalize)
1
gravatar for Jiang, Mike
4.1 years ago by
Jiang, Mike1.2k
(Private Address)
Jiang, Mike1.2k wrote:

Try this

fs_scaled <- fsApply(fs_initial, FUN = function(fr){
                                      mat <- exprs(fr)
                                      exprs(fr) <- scale(mat)
                                      fr
                                      }) 

 

ADD COMMENTlink written 4.1 years ago by Jiang, Mike1.2k
Answer: flowcore: z-Score normalization of flowSet (fsApply or normalize)
0
gravatar for BenAbflack
4.1 years ago by
BenAbflack0
Zurich/Switzerland
BenAbflack0 wrote:

Thanks a lot Mike,

Your scheme worked, just had to find a workaround solution to only apply it to some chosen columns but in the end I just keep all of them.

Best, Jerg

 

 

ADD COMMENTlink written 4.1 years ago by BenAbflack0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 134 users visited in the last hour