flowcore: z-Score normalization of flowSet (fsApply or normalize)
3
0
Entering edit mode
BenAbflack • 0
@benabflack-8435
Last seen 9.2 years ago
Zurich/Switzerland

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)

flowcore fcs normalization flowstats • 2.8k views
ADD COMMENT
2
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 3.1 years ago
(Private Address)

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 COMMENT
1
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 3.1 years ago
(Private Address)

Try this

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

 

ADD COMMENT
0
Entering edit mode
BenAbflack • 0
@benabflack-8435
Last seen 9.2 years ago
Zurich/Switzerland

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 COMMENT

Login before adding your answer.

Traffic: 799 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