Scaling fcs files with flowCore
1
0
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 8 weeks ago

On 04/05/2016 12:15 AM, TODOROV HELENA p1001837 wrote:
>
> This is how I scale the matrix :
>
>
>
> > mat<-exprs(b)
>
> > scaled_matrix<-apply(mat,2,scale)
>
>
> ​> scaled_b<-new("flowFrame", exprs=scaled_matrix, parameters=parameters(b), description=description(b))
> ​> write.FCS(scaled_b, outFile)
>
> But I have issues reading the generated fcs file. I suppose it may come from the fact that description parameters such as $PnE,$PnR, MaxRange... no longer correspond to the values of parameters?
>
> Also, could you tell me why the "transformation = "scale" " option from the read.FCS() function does not transform the data so that each markers mean = 0 and sd = 1?
>
> Helena
>>
>>
>
> De : Mike <wjiang2@fhcrc.org>
> Envoyé : lundi 4 avril 2016 20:01
> À : TODOROV HELENA p1001837
> Cc : Emilie Westeel
> Objet : Re: Scaling fcs files with flowCore
>
> What kind of scaling method do you use to transform the data?
>
> On 03/29/2016 03:08 AM, TODOROV HELENA p1001837 wrote:
>>
>> Dear Dr Jiang,
>>
>>
>> I've encountered some issues to scale my fcs data. I use the function :
>>
>>
>>
>>
>> ​But the transformed data are not scaled per marker. Indeed, if I check the summary of the object I generated, the mean for each marker is different from 0 and the sd is different from 1 (I attached a screenshot of this summary to this mail). Is there any way to scale the data per marker with flowCore/ or another Bioconductor package?
>>
>>
>> Also, I transformed my data manually (by extracting the matrix and scaling it per column), but the files I regenerate with the following functions :
>>
>>
>> > scaled_b<-new("flowFrame", exprs=scaled_matrix, parameters=parameters(b), description=description(b))
>>
>>
>> > write.FCS(scaled_b, outFile)
>>
>> present some problems when I try to read them with cytometry data analysis tools such as Phenograph, Visne, Scaffold. I tried to change some parameters manually, like the Rmin Rmax ranges that changed when I scaled the exprs matrix, which worked for some files but not for all, and which is also very time consuming. So I was wondering if there was any way to efficiently regenerate a description and parameters which correspond to the new matrix I generate, to create an FCS file that would be readable again?
>>
>>
>> Helena Todorov
>>

flowCore flowcytometry • 1.3k views
0
Entering edit mode
Jiang, Mike ★ 1.3k
@jiang-mike-4886
Last seen 8 weeks ago

The behavior of transformation="scale" in 'read.FCS' is not as what you thought. Type '?read.FCS' to read more carefully about 'transformation' argument. It is actually about  'logarithmic amplification'  when the data is stored as 'logarithmic scale'.  See '\$PnE' section of 'FCS3.1 standard'(http://isac-net.org/PDFS/90/9090600d-19be-460d-83fc-f8a8b004e0f9.pdf) for more details.

Based on what you've described, your custom transformation should be done through 'transform' method after 'fcs' is loaded. e.g.

data("GvHD")
fr <- GvHD[[1]]
chnl_to_transform <- c("FL1-H", "FL2-H")
translist <- transformList(chnl_to_transform, scale)
fr_trans <- transform(fr, translist)

Type '?transformList' for more help on this.

0
Entering edit mode

Thank you Mike, this function is working perfectly !