# Tag Info

7

Single-cell analysis to compare samples is a long a difficult process. There is very good documentation for 10x Genomics cellranger, the DropSeq Pipeline and the Seurat R package. These tools all have GitHub repositories and the authors are very responsive if you encounter issues. Depending on the technology used to generate the data, you'll need to use ...

6

Assuming you have an informative selection of variable genes from which you have constructed a number of useful PCs, I'd run a number of iterations with FindClusters() as described in the other answer, then choose a level which overclusters the dataset (for example, clusters that are visibly separate on a t-SNE or other dimensionality reduction plot should ...

6

I was able to achieve this in the following way: require(data.table) cell_names <- vector(mode="character") for (i in 1:length(neuron_ids)) { seurat_subset <- SubsetData(seurat_object, subset.name = neuron_ids[i], accept.low = 0.1) genes <- colnames(seurat_subset@data) cell_names <- c(cell_names, genes[! genes %chin% cell_names]) } ...

5

You can take a look at the recently published article: Bias, robustness and scalability in single-cell differential expression analysis. We evaluated 36 approaches using experimental and synthetic data and found considerable differences in the number and characteristics of the genes that are called differentially expressed. Prefiltering of lowly expressed ...

5

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 ...

5

I don't think this is possible in Seurat v2, but in v3 you can change the factor levels of the grouping variable to change the plot order: library(Seurat) FeaturePlot(object = pbmc_small, features = head(VariableFeatures(pbmc_small), 2), split.by = 'groups') Change the order: pbmc_small$groups <- factor(pbmc_small$groups, ...

5

This can be solved like this: library(Seurat) my_genes <- c("gene1", "gene2", "gene3") exp <- FetchData(object, my_genes) matrix <- as.matrix(colMeans(exp > 0))*100

5

In the linked article the authors formalize microarray analysis as the study of the joint distributions of $\overrightarrow{X}_i$ and $Y_i$, where $\overrightarrow{X}_i$ is a vector of random variables, the distribution of each of which (i.e. each of $X_{ji}$) is determined by the level of expression of gene j in sample i, and $Y$ is some response or ...

5

For merging dataframes, I find it easiest to use the tidyverse / dplyr functions inner/full/left/right_join. See the "Data Transformation Cheatsheet" on this page. For the merge that @user438383 has mentioned, this would be a left_join: library(tidyverse) anno <- data.frame(cluster = 1:6, celltype = c("T:CD4+NAIVE", "T:CD4+NAIVE&...

4

The counts stored in the Seurat object are: raw counts (seuratobject@raw.data), the log + normalized counts (seuratobject@data), and the scaled counts (seuratobject@scale.data). FeaturePlot() plots the log + normalized counts. In order to identify double-positive cells, you need to identify cells that express a gene (i.e. positive for a gene) and that is ...

4

You want to (1) see the mean for each gene, and also to (2) calculate a ratio of expression levels of two genes, then compare it between clusters. (1) First, notice that vlnPlot() is deprecated. Use VlnPlot(). You can try using the parameter do.sort=T: VlnPlot(object=seuset, features.plot=c("DDB_G0267412", "DDB_G0277853"), do.sort=T) Alternatively, you ...

4

This was addressed by the Seurat developers here: if you have TPM counts, I suggest you don't use Seurat::NormalizeData(), since TPM counts are already normalized for sequencing depth and transcript/gene length. Note that Seurat::NormalizeData() normalizes the data for sequencing depth, and then transforms it to log space. If you have TPM data, ...

4

Here is a solution using dplyr and ggplot2: library(Seurat) library(dplyr) library(ggplot2) meta.data <- pbmc_small[[]] # create random classifications for the sake of this example meta.data\$condition <- sample(c('A', 'B', 'C'), nrow(meta.data), replace = TRUE) counts <- group_by(meta.data, condition, res.1) %>% summarise(count = n()) ggplot(...

3

Below a few lines of code that accompany BC Wang's answer. After using MergeSeurat the sample name will be added to meta data under orig.ident. this can then be used to color the tSNE either using group.by or pt.shape. The former will show colors for each sample, the latter will color each cluster and give sample id another shape. path1 <- file.path("...

3

This is what packages like FateID and Monocle are for, namely taking single-cell RNAseq data and inferring differentiation trajectories from it. Don't try to reinvent the wheel on this, there are a number of packages out there to do this sort of thing and they're going to have pretty complicated methods that you're really not going to want to reinvent unless ...

3

In case it is still helpful as the post is rather old, the code below would generate a heatmap with annotations thanks to the ComplexHeatmap package. But before that I would like to stress out the importance of example data, I bet a lot of experts could not help you just because of they did not have single cell data at their disposal. I am using some scRNA-...

3

I tried with some data that I have and this is working for me: p <- FeaturePlot(object = seurat_object, features.plot = id, cols.use = c("grey", "blue"), reduction.use = "tsne", do.return = TRUE) lapply(p, function(x){x + labs(title = endothelial_symbols[1])}) I think it is because FeaturePlot returns several ggplot objects ...

3

That is a very general recommendation. Depending on your experiment, you can get a very different number of clusters with the same number of cells at the same resolution. You can actually use a vector of different resolutions and see which one performs best: pbmc_small <- FindClusters( object = pbmc_small, reduction.type = "pca", resolution = c(0....

3

I think you are looking to FindAllMarkers function from Seurat. As you said, you just have to define your ident, that have to have the structure of a table (cell names as names and cluster as value): pident=as.factor(clusters) names(pident)=cellNames object1@ident=pident And then run the FindAllMarkers function: FindAllMarkers(object1, min.pct = 0.25, ...

3

The expression values for each gene are scaled / standardized by subtracting the genes mean expression and dividing by its standard deviation. A value of -1 would imply it's one standard deviation below the mean expression for that gene.

3

There is a way to do this, and even better--there is documentation for how to do it! No surprise coming from the Satija Lab. In the vignette they perform multidimensional scaling, but the idea is the same. cmdscale() returns the cell embeddings. SetDimReduction() is the Seurat function you are looking for. No manual editing using @ required. The authors use ...

3

TSNEPlot() TSNEPlot() will always treat your variables as discrete. My approach is to manually generate a gradient with unique colors for each factor level and pass it to the cols.use argument in TSNEPlot(). #generate values for testing purposes, one value for each cell value <- sample(seq(from=8, to=48, by=1), size = length(rownames(unfiltered_cca@...

3

If you would like to color discrete intervals on a gradient as opposed to having a continuous gradient (like your second plot), use this approach. It is similar to the approach in the answer I posted with the continuous scale, but we simply break up the continuous scale in to intervals and color them by these intervals. #generate values for testing ...

3

You can get the table that is used to make the dot plot if you modify the DotPlot function to return it instead of the ggplot, and use the argument do.return=T. To edit the function, the command is: trace("DotPlot",edit=TRUE) Then replace the last line "return(p)" by "return(data.to.plot)" and save the edit. You can call the function and store the return ...

3

The PCHeatmap function (renamed DimHeatmap in Seurat v3) can be used to help determine the number of principal components to use in downstream analysis, as well as to visualize the top genes contributing to each PC. Both cells and genes are ordered by their PC scores, and by default the 15 genes with the highest and 15 genes with the lowest PC loadings are ...

3

You can stash anything you like in the misc slot (present in both v2 and v3 Seurat objects). I often use it for storing marker information to help with organization.

3

Given that it is virtually impossible for a human to predict what random numbers will be generated given a certain seed, and what effects they will have for a given application, the choice of the seed can be considered arbitrary. What matters is that fixing the seed should fix the behaviour of the application. What seed has been chosen does not really ...

3

Your cluster labels come from graph clustering implemented in the FindClusters() function. The resulting clusters are then visualised with a 2D tSNE plot (via RunTSNE() and TSNEPlot()). So, your cluster 13 is not split into three sub-clusters but cells within cluster 13 look somewhat distant from each other on the tSNE plot. Having mentioned distances on a ...

3

Identifying 15 clusters from 500 cells is challenging. It will depend on the relative abundance of each cell type within the tissue. You can use the cell type frequencies found in the shortSeq data set to see what to expect from a 500 cell dataset using the howmanycells tool About the pc plots: The first is an elbowplot which explains how many variation is ...

3

Your interpretation of pct.1 and pct.2 is misguided. If pct.1 == 1, the given gene was detected in all of the cells. This carries no information about high expression or low expression in the cell, just that it was detected. avg_logFC is the indication of expression levels. So your expectation, that "we would instead expect the genes to be expressed at ...

Only top voted, non community-wiki answers of a minimum length are eligible