Body: <p>I have extracted microarray gene expression data from GEO using the <code>GEOquery</code> package in R. There are multiple probes per gene. Is there a way to select the best probe? If so, what would be the criteria and how can you do this? Maybe use <a href="https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-12-474" rel="nofollow noreferrer">Jetset probes</a> (=best quality probes) for this?</p>
  
  <p>Otherwise, would you use the average expression value of all probes for each gene? If so, how can you do this in R, please?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Edit after comment below:
  I like the suggestion proposed here: <a href="https://support.bioconductor.org/p/70133/" rel="nofollow noreferrer">https://support.bioconductor.org/p/70133/</a>, using this code:</p>
  
  <pre><code> Probesets=paste("a",1:200,sep="") # "fake probesets"
   Genes=sample(letters,200,replace=T)
   Value=rnorm(200)
   X=data.frame(Probesets,Genes,Value) # I edited this line, as it seemed to contain an error
   X=X[order(X<span class="math-container">$Value,decreasing=T),]
   Y=X[which(!duplicated(X$</span>Genes)),]
  </code></pre>
  
  <p>But, I do not understand it. How is the value for each gene in Y calculated? It was commented that this is the MAD, but calculating the Median Absolute Deviation (MAD) by hand results in a different value. Could anyone help, please? Thank you.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-16T04:02:08.640Z
Comments.Text: The post: https://bioinformatics.stackexchange.com/questions/3082/duplicate-gene-symbol-handling-in-geo-gene-expression-data/3083#3083 helped a little bit, but did not answer all my questions.
Comments.UserDisplayName: Sylvia Rodriguez
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-16T10:54:26.387Z
Comments.Text: Thank you. Lots of options! I still have a question. See edit above. Thank you.
Comments.UserDisplayName: Sylvia Rodriguez
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-16T11:39:55.937Z
Comments.Text: The trick is `duplicated()` being used with `!` and only after sorting `X` in decreasing order. Basically, you sort your "values" from higher to lower and `duplicated()` gives you FALSE if that particular "value" was never observed in the "array of interest". When you negate this with `!`, you only keep the first occurence of a particular value and this first occurence would be the highest as it was sorted already in the previous step.
Comments.UserDisplayName: haci
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-04-16T12:48:38.553Z
Comments.Text: Thank you for your answer. That is very clear now. Now I am only left with figuring out how to calculate the MAD in R, but I will search for that.
Comments.UserDisplayName: Sylvia Rodriguez
Tags: <r><microarray><gene-expression><geoquery>
Title: How can I collapse probes to single value per gene using GEOquery?
ThreadText: # How can I collapse probes to single value per gene using GEOquery?
  
  (Asked by: username_0 on 2020-04-16)
  
  I have extracted microarray gene expression data from GEO using the `GEOquery` package in R. There are multiple probes per gene. Is there a way to select the best probe? If so, what would be the criteria and how can you do this? Maybe use [Jetset probes](https://bmcbioinformatics.biomedcentral.com/articles/10.1186/1471-2105-12-474) (=best quality probes) for this?
  
  Otherwise, would you use the average expression value of all probes for each gene? If so, how can you do this in R, please?
  
  **EDIT**
  
  Edit after comment below:
  I like the suggestion proposed here: <https://support.bioconductor.org/p/70133/>, using this code:
  
  ```
   Probesets=paste("a",1:200,sep="") # "fake probesets"
   Genes=sample(letters,200,replace=T)
   Value=rnorm(200)
   X=data.frame(Probesets,Genes,Value) # I edited this line, as it seemed to contain an error
   X=X[order(X$Value,decreasing=T),]
   Y=X[which(!duplicated(X$Genes)),]
  
  ```
  
  But, I do not understand it. How is the value for each gene in Y calculated? It was commented that this is the MAD, but calculating the Median Absolute Deviation (MAD) by hand results in a different value. Could anyone help, please? Thank you.
  
  **Tags:** r, microarray, gene-expression, geoquery
  
  > **Comments:**
  > **username_0**: The post: https://bioinformatics.stackexchange.com/questions/3082/duplicate-gene-symbol-handling-in-geo-gene-expression-data/3083#3083 helped a little bit, but did not answer all my questions.  
  > **username_0**: Thank you. Lots of options! I still have a question. See edit above. Thank you.  
  > **username_1**: The trick is `duplicated()` being used with `!` and only after sorting `X` in decreasing order. Basically, you sort your "values" from higher to lower and `duplicated()` gives you FALSE if that particular "value" was never observed in the "array of interest". When you negate this with `!`, you only keep the first occurence of a particular value and this first occurence would be the highest as it was sorted already in the previous step.  
  > **username_0**: Thank you for your answer. That is very clear now. Now I am only left with figuring out how to calculate the MAD in R, but I will search for that.  
  
  ---
  
  ## 0 answers
  
  