Help with flowCore Package: Working through the HowTo
1
0
Entering edit mode
M. Jankowski ▴ 160
@m-jankowski-2199
Last seen 9.6 years ago
Hi all, Thank you all for your help of about 10 days ago as I worked through some installation problems with R and Bioconductor. I hope those are behind me. I tried using the "prada" package for awhile and became somewhat stumped. After reading through a few posts it sounded like the "flowCore" package might assist me in analzing my flow cytometry data. I try to analyze my data as directed in the "HowTo-flowCore.pdf" document found on the Bioconductor website. As the following code demonstrates I can create an individual 'flowFrame' from my *.fcs data. > library("flowCore") Loading required package: Biobase Loading required package: tools Welcome to Bioconductor Vignettes contain introductory material. To view, type 'openVignette()' or start with 'help(Biobase)'. For details on reading vignettes, see the openVignette help page. Loading required package: rrcov Scalable Robust Estimators with High Breakdown Point (version 0.3-05) KernSmooth 2.22 installed Copyright M. P. Wand 1997 > x <- readFCS("/home/mdj/Rdata/", transformation = FALSE, alter.names=TRUE); > summary(x) FSC.H SSC.H FL1.H FL2.H FL3.H FL1.A FL4.H Time Min. 0.0 0.0 0.0 0.0 0 0.0 0 0.0 1st Qu. 129.0 117.0 428.0 199.0 304 7.0 123 59.0 Median 225.0 181.0 651.0 307.0 700 96.0 323 122.0 Mean 338.3 271.3 639.4 369.2 650 240.3 308 160.6 3rd Qu. 378.8 273.0 795.0 468.0 902 332.8 396 186.0 Max. 62460.0 63610.0 64570.0 60770.0 64820 64320.0 60800 65340.0 > As you can see, I have some pretty far outliers in all the data sets. What procedure would I follow to gate the data to less than 800 for "FSC.H" and "SSC.H"? Further, how would I plot the result of the gated data? In the context of the HowTo I would call my question "2.1.4: Gating and Plotting a flowFrame" The flowSet discussion in the HowTo does cover filtering and gating. When I attempt to read my file in as a flowset I get errors. Section 2.2.1 give the instruction: > frames <- lapply(dir(system.file("extdata", "compdata", "data", + package = "flowCore"), full.names = TRUE), read.FCS) > as(frames, "flowSet") I'm not certain how to put my "/home/mdj/Rdata/" directory into the context of the system.file function. Here is my best attempt: > frames <= lapply("/home/mdj/data/Rdata/", readFCS) Error: object "frames" not found When I attempt "read.flowSet": > read.flowSet("/home/mdj/Rdata/") Error in readFCSheader(con) : This does not seem to be a valid FCS2.0 or FCS3.0 file > This is odd because 'readFCS' was able to read my file just fine. Using read.flowSet it is not a vaild FCS2.0 or FCS3.0 file? These errors have me stumped. I think the organization of this library is quite keen. I like the flowFrame object in what I think of as a flowSet vector (with nice header). Would someone show me how to: 1) gate my data for the 'flowFrame' object and then plot the gated data? 2) work my way through creating a flowSet object? I think my main problem is that I am clumsy with the system.file syntax. My apologies if these questions are answered elsewhere. If this is the case please point me in the right direction. Any and all help is appreciated. Thanks! Matt
• 2.0k views
ADD COMMENT
0
Entering edit mode
Byron Ellis ▴ 100
@byron-ellis-2138
Last seen 9.6 years ago
On 6/18/07, M. Jankowski <mjankowski at="" gmail.com=""> wrote: > Hi all, > > > As you can see, I have some pretty far outliers in all the data sets. > What procedure would I follow to gate the data to less than 800 for > "FSC.H" and "SSC.H"? Further, how would I plot the result of the gated > data? In the context of the HowTo I would call my question "2.1.4: > Gating and Plotting a flowFrame" Section 4 of the How To is entirely about filtering/gating with 4.3 being the section relevant to your question. In your case you probably want a rectangleGate of some sort. For example, Subset(x,rectangleGate("FSC.H"=c(0,800),"SSC.H"=c(0,800))) would cut your frame down to size. As for plotting, this is somewhat more difficult. The flowViz package has some facilities for plotting a gate onto a plot of the data, but you'd have to ask Deepayan about that---I've never actually used it. > > The flowSet discussion in the HowTo does cover filtering and gating. > When I attempt to read my file in as a flowset I get errors. > > Section 2.2.1 give the instruction: > > frames <- lapply(dir(system.file("extdata", "compdata", "data", > + package = "flowCore"), full.names = TRUE), read.FCS) > > as(frames, "flowSet") When reading from files it is almost always best to use read.flowSet, which automates much of this process. > > I'm not certain how to put my "/home/mdj/Rdata/" directory into the > context of the system.file function. Here is my best attempt: > > frames <= lapply("/home/mdj/data/Rdata/", readFCS) Your example differs from the example in the How To in two ways. First, the lapply() is actually performed on the directory listing. For example, lapply(dir("/home/mdj/data/Rdata",patt="\\.fcs$"),readFCS) is more likely to do what you want. The inclusion of a pattern ensures that only things with the "fcs" extension will be used. However, it mostly serves as an example by way of construction so you shouldn't need to use it unless you need to do something that read.flowSet cannot (like grab the FCS files from URLS or something). Also, you have <= instead of <-. <= is an inequality. Personally, I hate <- with a passion (b[b<-1] = 0. Whoops.) and thus tend to use just =, unless it is impossible for some reason (very rarely). > Error: object "frames" not found > > When I attempt "read.flowSet": > > > read.flowSet("/home/mdj/Rdata/") This is because the first parameter of read.flowSet is actually a pattern not a path (I know, the opposite of dir... but this is the way things go). This is because you're usually in the same directory as your FCS files. You actually want: read.flowSet(path="/home/mdj/Rdata/") or something similar. > These errors have me stumped. I think the organization of this library > is quite keen. I like the flowFrame object in what I think of as a > flowSet vector (with nice header). Would someone show me how to: > > 1) gate my data for the 'flowFrame' object and then plot the gated data? > 2) work my way through creating a flowSet object? I think my main > problem is that I am clumsy with the system.file syntax. > > My apologies if these questions are answered elsewhere. If this is the > case please point me in the right direction. > > Any and all help is appreciated. Thanks! > Hope that helps. > Matt > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Byron Ellis (byron.ellis at gmail.com) "Oook" -- The Librarian
ADD COMMENT
0
Entering edit mode
On 6/18/07, Byron Ellis <byron.ellis at="" gmail.com=""> wrote: > On 6/18/07, M. Jankowski <mjankowski at="" gmail.com=""> wrote: > > Hi all, > > > > > > As you can see, I have some pretty far outliers in all the data sets. > > What procedure would I follow to gate the data to less than 800 for > > "FSC.H" and "SSC.H"? Further, how would I plot the result of the gated > > data? In the context of the HowTo I would call my question "2.1.4: > > Gating and Plotting a flowFrame" > > Section 4 of the How To is entirely about filtering/gating with 4.3 > being the section relevant to your question. In your case you probably > want a rectangleGate of some sort. For example, > > Subset(x,rectangleGate("FSC.H"=c(0,800),"SSC.H"=c(0,800))) > > would cut your frame down to size. As for plotting, this is somewhat > more difficult. The flowViz package has some facilities for plotting a > gate onto a plot of the data, but you'd have to ask Deepayan about > that---I've never actually used it. Yes, flowViz does have some utilities for gates, but they didn't make it to BioC 2.0. You can get the development version from http://bioconductor.org/packages/2.1/bioc/html/flowViz.html (which also has a vignette), and it should work with 2.0 if you are lucky. It may not work with the current devel version of flowCore though. -Deepayan
ADD REPLY
0
Entering edit mode
Actually it probably works in devel as well, I haven't committed the big changeset yet---sidetracked by paper deadlines and WWDC. On 6/18/07, Deepayan Sarkar <deepayan.sarkar at="" gmail.com=""> wrote: > On 6/18/07, Byron Ellis <byron.ellis at="" gmail.com=""> wrote: > > On 6/18/07, M. Jankowski <mjankowski at="" gmail.com=""> wrote: > > > Hi all, > > > > > > > > > As you can see, I have some pretty far outliers in all the data sets. > > > What procedure would I follow to gate the data to less than 800 for > > > "FSC.H" and "SSC.H"? Further, how would I plot the result of the gated > > > data? In the context of the HowTo I would call my question "2.1.4: > > > Gating and Plotting a flowFrame" > > > > Section 4 of the How To is entirely about filtering/gating with 4.3 > > being the section relevant to your question. In your case you probably > > want a rectangleGate of some sort. For example, > > > > Subset(x,rectangleGate("FSC.H"=c(0,800),"SSC.H"=c(0,800))) > > > > would cut your frame down to size. As for plotting, this is somewhat > > more difficult. The flowViz package has some facilities for plotting a > > gate onto a plot of the data, but you'd have to ask Deepayan about > > that---I've never actually used it. > > Yes, flowViz does have some utilities for gates, but they didn't make > it to BioC 2.0. You can get the development version from > > http://bioconductor.org/packages/2.1/bioc/html/flowViz.html > > (which also has a vignette), and it should work with 2.0 if you are > lucky. It may not work with the current devel version of flowCore > though. > > > -Deepayan > -- Byron Ellis (byron.ellis at gmail.com) "Oook" -- The Librarian
ADD REPLY
0
Entering edit mode
Byron, This got me back on track! Thank you! Matt On 6/18/07, Byron Ellis <byron.ellis at="" gmail.com=""> wrote: > On 6/18/07, M. Jankowski <mjankowski at="" gmail.com=""> wrote: > > Hi all, > > > > > > As you can see, I have some pretty far outliers in all the data sets. > > What procedure would I follow to gate the data to less than 800 for > > "FSC.H" and "SSC.H"? Further, how would I plot the result of the gated > > data? In the context of the HowTo I would call my question "2.1.4: > > Gating and Plotting a flowFrame" > > Section 4 of the How To is entirely about filtering/gating with 4.3 > being the section relevant to your question. In your case you probably > want a rectangleGate of some sort. For example, > > Subset(x,rectangleGate("FSC.H"=c(0,800),"SSC.H"=c(0,800))) > > would cut your frame down to size. As for plotting, this is somewhat > more difficult. The flowViz package has some facilities for plotting a > gate onto a plot of the data, but you'd have to ask Deepayan about > that---I've never actually used it. > > > > > The flowSet discussion in the HowTo does cover filtering and gating. > > When I attempt to read my file in as a flowset I get errors. > > > > Section 2.2.1 give the instruction: > > > frames <- lapply(dir(system.file("extdata", "compdata", "data", > > + package = "flowCore"), full.names = TRUE), read.FCS) > > > as(frames, "flowSet") > > When reading from files it is almost always best to use read.flowSet, > which automates much of this process. > > > > > I'm not certain how to put my "/home/mdj/Rdata/" directory into the > > context of the system.file function. Here is my best attempt: > > > frames <= lapply("/home/mdj/data/Rdata/", readFCS) > > Your example differs from the example in the How To in two ways. > First, the lapply() is actually performed on the directory listing. > For example, > > lapply(dir("/home/mdj/data/Rdata",patt="\\.fcs$"),readFCS) > > is more likely to do what you want. The inclusion of a pattern ensures > that only things with the "fcs" extension will be used. However, it > mostly serves as an example by way of construction so you shouldn't > need to use it unless you need to do something that read.flowSet > cannot (like grab the FCS files from URLS or something). > > Also, you have <= instead of <-. <= is an inequality. Personally, I > hate <- with a passion (b[b<-1] = 0. Whoops.) and thus tend to use > just =, unless it is impossible for some reason (very rarely). > > > Error: object "frames" not found > > > > When I attempt "read.flowSet": > > > > > read.flowSet("/home/mdj/Rdata/") > > This is because the first parameter of read.flowSet is actually a > pattern not a path (I know, the opposite of dir... but this is the way > things go). This is because you're usually in the same directory as > your FCS files. You actually want: > > read.flowSet(path="/home/mdj/Rdata/") > > or something similar. > > > These errors have me stumped. I think the organization of this library > > is quite keen. I like the flowFrame object in what I think of as a > > flowSet vector (with nice header). Would someone show me how to: > > > > 1) gate my data for the 'flowFrame' object and then plot the gated data? > > > 2) work my way through creating a flowSet object? I think my main > > problem is that I am clumsy with the system.file syntax. > > > > My apologies if these questions are answered elsewhere. If this is the > > case please point me in the right direction. > > > > Any and all help is appreciated. Thanks! > > > > Hope that helps. > > > Matt > > > > _______________________________________________ > > Bioconductor mailing list > > Bioconductor at stat.math.ethz.ch > > https://stat.ethz.ch/mailman/listinfo/bioconductor > > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor > > > > > -- > Byron Ellis (byron.ellis at gmail.com) > "Oook" -- The Librarian >
ADD REPLY

Login before adding your answer.

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