Answers.Body: <p>Since I don't think it is possible to have two color schemes in a single plot (one for expression and one for highlighting some cells) I will suggest other approach. </p>
  
  <p>A possible option to do this could be to <strong>change the shape</strong> in the plot of the cells that you want to highlight and maintain the color code for expression.</p>
  
  <p>I add a code that works for this purpose with the <a href="https://drive.google.com/file/d/1rLsRXrxJPYm8cSzSqa5WUR6NYaUr-e9f/view?usp=sharing" rel="nofollow noreferrer">R object provided</a>. Maybe there are easier ways to do that but this is working: </p>
  
  <pre><code># Run PCA
  seuset_h16 &lt;- RunPCA(seuset_h16, 
                       pc.genes = seuset_h16@var.genes)
  # Run tSNE
  seuset_h16 &lt;- RunTSNE(object = seuset_h16, 
                        dims.use = 1:10, 
                        do.fast = TRUE)
  # Find clusters of cells
  seuset_h16 &lt;- FindClusters(object = seuset_h16, 
                             reduction.type = "pca", 
                             dims.use = 1:10, 
                             resolution = 0.6, 
                             print.output = 0, 
                             save.SNN = TRUE)
  # Store output from FeaturePlot (do.return = T)
  fp &lt;- FeaturePlot(object = seuset_h16, 
                    features.plot = c("DDB_G0273311"), 
                    cols.use = c("grey", "orange"), 
                    reduction.use = "tsne", 
                    do.return = T)
  # Add extra column in the data with the cells to be highligthed
  fp$DDB_G0273311$data$cellToDisplay &lt;- as.factor(ifelse(row.names(fp$DDB_G0273311$data) %in% c("s1.1", "s1.4", "s1.80"), 
  "group2", 
  "group1"))
  # Modify color and shape in the plot
  # lapply is needed since the object returned in fp is a list 
  lapply(fp, `+`, geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4)))
  </code></pre>
  
  <p>This is the output, with three cells highlighted as triangles and the rest as dots. You can play a little bit with shapes and sizes if you want a clearer display: 
  <a href="https://i.sstatic.net/TiyuG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/TiyuG.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T15:51:01.453Z
Answers.Text: First of all thanks a lot for your time, in last piece of code says so                                               > lapply(fp, `+`, geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4)))
  Error in FUN(X[[i]], ...) : non-numeric argument to binary operator
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T15:54:41.220Z
Answers.Text: Is working for me, but try with this: lapply(fp, function(x) { x + geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4))})
Answers.UserDisplayName: jxx_fa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T15:57:24.100Z
Answers.Text: Says that      > apply(fp, function(x) { x + geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4))})
  Error in match.fun(FUN) : argument "FUN" is missing, with no default
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T16:11:49.090Z
Answers.Text: I think you miss to copy the l from lapply. We are using the lapply function not apply function. Could be that?
Answers.UserDisplayName: jxx_fa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T15:33:54.073Z
Answers.LastActivityDate: 2018-06-13T15:33:54.073Z
Answers.UserDisplayName: jxx_fa
Answers.Body: <p>This updates the answer provided by Mack123456 to Seurat 3 and works in 3.1.2. There are some minor difference with colouring, but it is otherwise similar. The HoverLocator plot throws a warning, all about the plot colours and title, but the plot is fine and labels appear as expected.</p>
  
  <pre><code>load(file= "~/seuset_16.RData")
  
  seuset_h16 &lt;- UpdateSeuratObject(seuset_h16)
  
  high &lt;- c("s1.1","s1.4", "s1.80")
  low &lt;- setdiff(rownames(seuset_h16@meta.data), high)
  Idents(seuset_h16, cells = high) &lt;- "high"
  Idents(seuset_h16, cells = low) &lt;- "low"
  seuset_h16$expr &lt;- Idents(seuset_h16)
  Idents(object = seuset_h16) &lt;- "res.1"
  
  t &lt;- DimPlot(seuset_h16, pt.size = 2, shape.by = "expr")
  t
  
  t2 &lt;- DimPlot(seuset_h16, pt.size = 2, cols = c("red", "orange","green","blue"))
  t2 &lt;- HoverLocator(plot = t2, information = FetchData(object = seuset_h16, vars = c("ident", "res.1")))
  t2
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-17T00:37:41.667Z
Answers.LastActivityDate: 2020-01-17T00:37:41.667Z
Answers.UserDisplayName: Kieran Short
Answers.Body: <p>To color the TSNEPlot, you can generate a new column in metadata with the expression levels (High, low, etc). Then use pt.shape to set a shape for each identity.</p>
  
  <p>To show binary expression based on expression you first have to define the list of cells that are below or over your threshold. Once you have those lists you can use SetIdent() in Seurat to color those groups. </p>
  
  <pre><code>load(file= "~/seuset_16.RData")
  
  high &lt;- c("s1.1","s1.4", "s1.80")  
  low &lt;- setdiff(colnames(seuset_h16@data), high)  
  seuset_h16 &lt;- SetIdent(seuset_h16, cells.use = high, ident.use = "high")  
  seuset_h16 &lt;- SetIdent(seuset_h16, cells.use = low, ident.use = "low") 
  seuset_h16 &lt;- StashIdent(seuset_h16, save.name = "expr")  
  seuset_h16 &lt;- SetAllIdent(seuset_h16, id="res.1")  
  t &lt;- TSNEPlot(seuset_h16, pt.size = 2, do.return = T, pt.shape ="expr")  
  t
  </code></pre>
  
  <p><a href="https://i.sstatic.net/z9ELG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/z9ELG.png" alt="enter image description here"></a></p>
  
  <pre><code>high &lt;- c("s1.1","s1.4", "s1.80")  
  low &lt;- setdiff(colnames(seuset_h16@data), high)  
  seuset_h16 &lt;- SetIdent(seuset_h16, cells.use = high, ident.use = "high")  
  seuset_h16 &lt;- SetIdent(seuset_h16, cells.use = low, ident.use = "low")   
  t &lt;- TSNEPlot(seuset_h16, pt.size = 2, do.return = T, colors.use = c("red", "grey"), do.hover =T, data.hover =c("ident", "res.1))  
  t
  </code></pre>
  
  <p><a href="https://i.sstatic.net/o1dmF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/o1dmF.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T18:14:57.910Z
Answers.Text: Excuse me, I have 4 clusters made by these 209 cells so I want to know the exact location  of cells that are below or over the threshold. For example cell 183 itself places in cluster 0. My question is, by your code is the location of my cells will change in tSNE plot or 4 clusters be reserved???? For instance, this is a link of a picture of my original tSNE plot, I want to know the location of a cell in clusters as it has already been                     https://drive.google.com/file/d/1ipXg2Nb9lM_JgIH6WgVV-PoLhEtzLWif/view?usp=sharing
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T18:45:23.577Z
Answers.Text: Sorry, by doing hover I noticed all of cells have been labelled by 1, and high or low ident. That means I can't differentiate the cluster identities anymore (clusters 0, 1, 2, 3). How can color the cells and knowing their cluster identities?
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T18:58:42.190Z
Answers.Text: The cluster identity doesn't change, you can add data.hover = c("ident", "res.1"). res.1 is the column name for your clustering at resolution 1 that can be found in object@meta.data. By including this in data.hover you will be able to see the cluster number.
Answers.UserDisplayName: Mack123456
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T21:15:15.463Z
Answers.Text: Just edited based on your questions. please upvote answer if this helped. I am new and starting to build reputation! best of luck with your data
Answers.UserDisplayName: Mack123456
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-14T16:09:26.687Z
Answers.Text: Yes and no. Using 3 color schemes won't work but you can leverage the ggplot shapes for this. shape 21-25 allow you to have both fill and color.  do.return = T, returns a ggplot object and using geom_point() allows you to set a shape. You can then use different schemes. for example high threshold open and low threshold filled shapes. What is the scientific information/answer you want to display. There are probably much simpler ways to convey that information.
Answers.UserDisplayName: Mack123456
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-14T17:12:10.843Z
Answers.Text: Sorry, maybe nonsense, I have two lists of genes each have been established to be markers of a developmental stage. you think is there a way to relate my four clusters to these developmental stages based on these two lists?
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-13T17:02:58.897Z
Answers.LastActivityDate: 2019-04-10T13:29:17.837Z
Answers.LastEditDate: 2019-04-10T13:29:17.837Z
Answers.UserDisplayName: Mack123456
Body: <p>I have 209 cells, I clustered them by Seurat to 4 clusters. By Featureplot I am able to track a gene in clusters:</p>
  
  <p><a href="https://i.sstatic.net/3uIq9.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/3uIq9.png" alt="enter image description here"></a>
  Higher color shows higher expression. </p>
  
  <p>Now, for some genes I want to highlight some cells in Featureplot so that apart from yellow or red colours I want to colour a subsets of cells with another color. I mean I want to map a list of cells in Featureplot or tSNE plot. Let's say I want to know the location of cells 1, 4, 80 and highlight them with another color. 
  My Seurat object in this <a href="https://drive.google.com/file/d/1rLsRXrxJPYm8cSzSqa5WUR6NYaUr-e9f/view?usp=sharing" rel="nofollow noreferrer">link</a>.</p>
  
  <p>Seurat itself beautifully maps the cells in Featureplot for defined genes with a gradient of colours showing the level of expression. Saying I have genes A and B, in <a href="https://drive.google.com/file/d/1sks1fwe2yWCQp8n7WFUB480pnECBdhPk/view?usp=sharing" rel="nofollow noreferrer">excel</a>.</p>
  
  <p>I have coloured cells that express a gene > mean + se, &lt; mean - se or between these values. For instance, for this gene, 36 cells express this gene > mean + se, I want to map these cells in Featureplot or tSNE plot in distinct colour so I can locate them in clusters easily. Something like binary (on off) expression to relative expression.</p>
  
  <p>How I can change the colour of some cells based on my threshold for this gene please?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-13T14:59:54.330Z
Comments.Text: Do you mean in this exact plot to put a separated color for the cells you want? I don't think this is possible. From what I know, you can put a color code based on gene expression (the situation in your plot) or a color code for a group of cells you want to highlight. But as far as I know both options are incompatible. One thing you can do its to color cells based on gene expression and then highlight the cells you want in a different way. For instance, changing its shape from a dot to a triangle. Do you think this could fit your needs?
Comments.UserDisplayName: jxx_fa
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-13T15:16:47.730Z
Comments.Text: Thanks a lot, I think yes. I don't know how to ask Seurat to change the max and min of expression of a certain gene based on my desire. That would be nice if I could color my 209 cells for gene A, if gene A is expression > mean + se, < mean + se, or whatever criteria. The problem is this, in current Featureplot I don't know if a red cell is expressing genes A and B equally, higher or lower.
Comments.UserDisplayName: Zizogolu
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-06-13T15:17:27.397Z
Comments.Text: I will put an answer of how to do it because it is a little bit tricky
Comments.UserDisplayName: jxx_fa
Tags: <r><single-cell><seurat><ggplot2>
Title: Mapping a list of cells in seurat featureplot
ThreadText: # Mapping a list of cells in seurat featureplot
  
  (Asked by: username_0 on 2018-06-12)
  
  I have 209 cells, I clustered them by Seurat to 4 clusters. By Featureplot I am able to track a gene in clusters:
  
  [![enter image description here](https://i.sstatic.net/3uIq9.png)](https://i.sstatic.net/3uIq9.png)
  Higher color shows higher expression.
  
  Now, for some genes I want to highlight some cells in Featureplot so that apart from yellow or red colours I want to colour a subsets of cells with another color. I mean I want to map a list of cells in Featureplot or tSNE plot. Let's say I want to know the location of cells 1, 4, 80 and highlight them with another color.
  My Seurat object in this [link](https://drive.google.com/file/d/1rLsRXrxJPYm8cSzSqa5WUR6NYaUr-e9f/view?usp=sharing).
  
  Seurat itself beautifully maps the cells in Featureplot for defined genes with a gradient of colours showing the level of expression. Saying I have genes A and B, in [excel](https://drive.google.com/file/d/1sks1fwe2yWCQp8n7WFUB480pnECBdhPk/view?usp=sharing).
  
  I have coloured cells that express a gene > mean + se, < mean - se or between these values. For instance, for this gene, 36 cells express this gene > mean + se, I want to map these cells in Featureplot or tSNE plot in distinct colour so I can locate them in clusters easily. Something like binary (on off) expression to relative expression.
  
  How I can change the colour of some cells based on my threshold for this gene please?
  
  **Tags:** r, single-cell, seurat, ggplot2
  
  > **Comments:**
  > **username_1**: Do you mean in this exact plot to put a separated color for the cells you want? I don't think this is possible. From what I know, you can put a color code based on gene expression (the situation in your plot) or a color code for a group of cells you want to highlight. But as far as I know both options are incompatible. One thing you can do its to color cells based on gene expression and then highlight the cells you want in a different way. For instance, changing its shape from a dot to a triangle. Do you think this could fit your needs?  
  > **username_0**: Thanks a lot, I think yes. I don't know how to ask Seurat to change the max and min of expression of a certain gene based on my desire. That would be nice if I could color my 209 cells for gene A, if gene A is expression > mean + se, < mean + se, or whatever criteria. The problem is this, in current Featureplot I don't know if a red cell is expressing genes A and B equally, higher or lower.  
  > **username_1**: I will put an answer of how to do it because it is a little bit tricky  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2018-06-13. Score: 5 | Accepted answer
  
  To color the TSNEPlot, you can generate a new column in metadata with the expression levels (High, low, etc). Then use pt.shape to set a shape for each identity.
  
  To show binary expression based on expression you first have to define the list of cells that are below or over your threshold. Once you have those lists you can use SetIdent() in Seurat to color those groups.
  
  ```
  load(file= "~/seuset_16.RData")
  
  high <- c("s1.1","s1.4", "s1.80")  
  low <- setdiff(colnames(seuset_h16@data), high)  
  seuset_h16 <- SetIdent(seuset_h16, cells.use = high, ident.use = "high")  
  seuset_h16 <- SetIdent(seuset_h16, cells.use = low, ident.use = "low") 
  seuset_h16 <- StashIdent(seuset_h16, save.name = "expr")  
  seuset_h16 <- SetAllIdent(seuset_h16, id="res.1")  
  t <- TSNEPlot(seuset_h16, pt.size = 2, do.return = T, pt.shape ="expr")  
  t
  
  ```
  
  [![enter image description here](https://i.sstatic.net/z9ELG.png)](https://i.sstatic.net/z9ELG.png)
  
  ```
  high <- c("s1.1","s1.4", "s1.80")  
  low <- setdiff(colnames(seuset_h16@data), high)  
  seuset_h16 <- SetIdent(seuset_h16, cells.use = high, ident.use = "high")  
  seuset_h16 <- SetIdent(seuset_h16, cells.use = low, ident.use = "low")   
  t <- TSNEPlot(seuset_h16, pt.size = 2, do.return = T, colors.use = c("red", "grey"), do.hover =T, data.hover =c("ident", "res.1))  
  t
  
  ```
  
  [![enter image description here](https://i.sstatic.net/o1dmF.png)](https://i.sstatic.net/o1dmF.png)
  
  > **Comments:**
  > **username_0**: Excuse me, I have 4 clusters made by these 209 cells so I want to know the exact location  of cells that are below or over the threshold. For example cell 183 itself places in cluster 0. My question is, by your code is the location of my cells will change in tSNE plot or 4 clusters be reserved???? For instance, this is a link of a picture of my original tSNE plot, I want to know the location of a cell in clusters as it has already been                     https://drive.google.com/file/d/1ipXg2Nb9lM_JgIH6WgVV-PoLhEtzLWif/view?usp=sharing  
  > **username_0**: Sorry, by doing hover I noticed all of cells have been labelled by 1, and high or low ident. That means I can't differentiate the cluster identities anymore (clusters 0, 1, 2, 3). How can color the cells and knowing their cluster identities?  
  > **username_3**: The cluster identity doesn't change, you can add data.hover = c("ident", "res.1"). res.1 is the column name for your clustering at resolution 1 that can be found in object@meta.data. By including this in data.hover you will be able to see the cluster number.  
  > **username_3**: Just edited based on your questions. please upvote answer if this helped. I am new and starting to build reputation! best of luck with your data  
  > **username_3**: Yes and no. Using 3 color schemes won't work but you can leverage the ggplot shapes for this. shape 21-25 allow you to have both fill and color.  do.return = T, returns a ggplot object and using geom_point() allows you to set a shape. You can then use different schemes. for example high threshold open and low threshold filled shapes. What is the scientific information/answer you want to display. There are probably much simpler ways to convey that information.  
  > **username_0**: Sorry, maybe nonsense, I have two lists of genes each have been established to be markers of a developmental stage. you think is there a way to relate my four clusters to these developmental stages based on these two lists?  
  
  ---
  
  ### Answer by username_1 on 2018-06-13. Score: 2
  
  Since I don't think it is possible to have two color schemes in a single plot (one for expression and one for highlighting some cells) I will suggest other approach.
  
  A possible option to do this could be to **change the shape** in the plot of the cells that you want to highlight and maintain the color code for expression.
  
  I add a code that works for this purpose with the [R object provided](https://drive.google.com/file/d/1rLsRXrxJPYm8cSzSqa5WUR6NYaUr-e9f/view?usp=sharing). Maybe there are easier ways to do that but this is working:
  
  ```
  # Run PCA
  seuset_h16 <- RunPCA(seuset_h16, 
                       pc.genes = seuset_h16@var.genes)
  # Run tSNE
  seuset_h16 <- RunTSNE(object = seuset_h16, 
                        dims.use = 1:10, 
                        do.fast = TRUE)
  # Find clusters of cells
  seuset_h16 <- FindClusters(object = seuset_h16, 
                             reduction.type = "pca", 
                             dims.use = 1:10, 
                             resolution = 0.6, 
                             print.output = 0, 
                             save.SNN = TRUE)
  # Store output from FeaturePlot (do.return = T)
  fp <- FeaturePlot(object = seuset_h16, 
                    features.plot = c("DDB_G0273311"), 
                    cols.use = c("grey", "orange"), 
                    reduction.use = "tsne", 
                    do.return = T)
  # Add extra column in the data with the cells to be highligthed
  fp$DDB_G0273311$data$cellToDisplay <- as.factor(ifelse(row.names(fp$DDB_G0273311$data) %in% c("s1.1", "s1.4", "s1.80"), 
  "group2", 
  "group1"))
  # Modify color and shape in the plot
  # lapply is needed since the object returned in fp is a list 
  lapply(fp, `+`, geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4)))
  
  ```
  
  This is the output, with three cells highlighted as triangles and the rest as dots. You can play a little bit with shapes and sizes if you want a clearer display:
  [![enter image description here](https://i.sstatic.net/TiyuG.png)](https://i.sstatic.net/TiyuG.png)
  
  > **Comments:**
  > **username_0**: First of all thanks a lot for your time, in last piece of code says so                                               > lapply(fp, `+`, geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4))) Error in FUN(X[[i]], ...) : non-numeric argument to binary operator  
  > **username_1**: Is working for me, but try with this: lapply(fp, function(x) { x + geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4))})  
  > **username_0**: Says that      > apply(fp, function(x) { x + geom_point(aes(shape=cellToDisplay, colour = gene, size = 0.4))}) Error in match.fun(FUN) : argument "FUN" is missing, with no default  
  > **username_1**: I think you miss to copy the l from lapply. We are using the lapply function not apply function. Could be that?  
  
  ---
  
  ### Answer by username_2 on 2020-01-17. Score: 0
  
  This updates the answer provided by username_3 to Seurat 3 and works in 3.1.2. There are some minor difference with colouring, but it is otherwise similar. The HoverLocator plot throws a warning, all about the plot colours and title, but the plot is fine and labels appear as expected.
  
  ```
  load(file= "~/seuset_16.RData")
  
  seuset_h16 <- UpdateSeuratObject(seuset_h16)
  
  high <- c("s1.1","s1.4", "s1.80")
  low <- setdiff(rownames(seuset_h16@meta.data), high)
  Idents(seuset_h16, cells = high) <- "high"
  Idents(seuset_h16, cells = low) <- "low"
  seuset_h16$expr <- Idents(seuset_h16)
  Idents(object = seuset_h16) <- "res.1"
  
  t <- DimPlot(seuset_h16, pt.size = 2, shape.by = "expr")
  t
  
  t2 <- DimPlot(seuset_h16, pt.size = 2, cols = c("red", "orange","green","blue"))
  t2 <- HoverLocator(plot = t2, information = FetchData(object = seuset_h16, vars = c("ident", "res.1")))
  t2
  
  ```
  
  
  ---
  
  