# Tag Info

6

I'm not fully to have understood your second questions, but first, if you want to scale the density to 1, you can use y= ..scaled.. in your aes: library(tidyverse) df %>% pivot_longer(., everything(), names_to = "Variable", values_to = "Value") %>% ggplot(., aes(x = Value, y = ..scaled.., fill = Variable)) + geom_density(alpha = 0....

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

You don't have any continuous fill scales, since you're filling according to Condition, which is a factor. This is leading to the Error: Discrete value supplied to continuous scale error. You just need to combine your previous scale_fill_manual(values=...) command with the labels= part of your incorrect scale_fill_continuous() command: ggplot(dataset, aes( ...

5

I would strongly discourage you from making discontinuous axis, it's going to be very confusing for a reader. The facet plot you proposed seems like a good solution to me. Alternatively you can use log transformation. To demonstrate I made it on simulated data that look appox like yours : set.seed(940401) data.plot <- data.frame(Methyl_Average = c(0....

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(... 4 I was curious how they have done it as well, so here expanded @Liopis comment : wget http://bioconductor.org/packages/release/bioc/src/contrib/DRIMSeq_1.6.0.tar.gz tar -zxf DRIMSeq_1.6.0.tar.gz # if you need to find it, or use grep # find DRIMSeq -name "dm_plotProportions.R" less DRIMSeq/R/dm_plotProportions.R 4 Axes for ggplots can be controlled via xlim() and ylim() functions. You can try: your_ggplot_object + ylim(-5,20) # assuming that you want the gene labels to be readabe, not clear from your post 4 I have noticed a few errors: 1) You define a bunch of variables (Species, Class, ...) but then instead of creating your data frame data with these you create it by reading from text. I don't think this is good practice, you should do so like in your example code. 2) With the way you define, your data frame does not contain columns like Class or Species but ... 4 As you did for labeling genes with an adjusted p value below 0.05, you can subset your dataset for keeping only rows corresponding to "Casp14": library(ggplot2) library(ggrepel) ggplot(final_tumor, aes(x = Log2.fold.change,y = -log10(Adjusted.p.value), label = Feature.Name))+ geom_point()+ geom_text_repel(data = subset(final_tumor, Adjusted.p.value <... 4 What you are looking for is facetting. Using this key word on any search engines you will find dozen of answers describing its use: https://ggplot2.tidyverse.org/reference/facet_grid.html and https://ggplot2.tidyverse.org/reference/facet_wrap.html To prepare the faceting in ggplot2, a possible way is to bind both dataframes together by first specifying ... 4 You can accomplish this using the ggtree package available on Bioconductor. First you will need to combine your tree with the data. library(tidyverse) library(ggtree) ftree <- tree$edge %>% as_tibble() %>% mutate(Node_number = 1:n()) %>% # finds edge numbering right_join(data, by = "Node_number") %>% # find internal node ...

3

Couple of things regarding your code: It would be good to have your data frame in long format for ggplot2 For having the x-axis ordered chronologically, you have to specify it manually, otherwise it is ordered alphabetically. Then, here is my solution: library(ggplot2) library(reshape2) # I have substituted your <- by = and changed the name of the ...

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

The adjustcolor function from grDevices can be used to generate colours with transparency. What you want is colours based on the pathway and transparency to form a colour gradient for the p-value. adjustcolor( "red", alpha.f = 0.2) For the ggplot example, the aes function has an alpha parameter. ggplot(df2, aes(x = factor(Pathway_names), y = ...

3

You add the points with geom_point(). Just remove it and you will get your "empty" boxplot. q <- ggboxplot(B, x = "Type", y = "Gene", color = "black", palette = "npg", ylab = 'Gene expression', xlab=FALSE, order=c("Normal", "Tumor")) Unfortunately I couldn't use stat_compare_means(method = "t.test") and ...

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

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

Here a way to do it is to start first by creating a dataset containing your three different group, based on the few lines you display: dat1$Condition = "dat1" dat2$Condition = "dat2" dat3$Condition = "dat3" colnames(dat1)[1] = "Patient" DF <- rbind(dat1,dat2,dat3) Patient DEL INS SNP total Condition 1: LP6008337-DNA_H06 927 773 ... 3 If you had the classification into oncogene/TSG for each gene in a column (let's call it gene_class) in lmuts, you could split both groups into facets within the plot by adding: + facet_wrap(~gene_class, ncol=1) 3 The problem is the scale used: For the plot you called "weird" (first from the top), the scale is 50 and for the "ggplot only" (third from the top) the scale is 1. You should play with the stat_compare_means(label.y = 50) bit, you can try setting the label.y parameter to 1.5 or 2. EDIT BECAUSE OF THE ADDITIONAL REMARKS ON THE QUESTION: Once again (and for ... 3 It is not like your conventional frequency which adds up to one. The density is low because the width of your bins is huge, and the number of observations you have is low. From this by Wickham, the basic kernel is: where K is the kernel and h is the bandwidth (Scott, 1992b) If you don't specify it, by default h will revert to nrd0: library(rtracklayer) ... 2 Maybe try plot(evecdat$PC1, evecdat$PC2, xlab="PC1", ylab="PC2", pch="24", cex.lab=2.5, cex.axis=1, type="n") text(evecdat$PC1, evecdat$PC2, evecdat$Sample, col=as.vector(evecdat$color)) This should plot the sample names as text (taken from the evecdat$Sample column), colored as specified in the evecdat$color column. See ?text for details. 2 You'll want to use long-form data for everything: library(dplyr) library(ggplot2) logCPM$gene = row.names(logCPM) d = logCPM %>% gather(Sample, logCPM, -gene) d$group = c(rep("Tumor", 2), rep("Normal", 2)) geneOfInterest = d %>% filter(gene == 'RP11-351J23.1') ggplot(geneOfInterest, aes(x=group, y=logCPM)) + geom_violin() That's a simple example, you ... 2 The normalized and log-transformed values are used for the violin plot. The argument y.log changes only the display of the data (scaling of the y axis). Seurat has very good documentation. Section 7 in the FAQ explains what data is stored in the object: How is data stored within the Seurat object? What is the difference between raw.data, data, and scale.... 2 Those two graphs don't look radically different. The y axis is definitely not log scaled on the top one, and it looks like it is scaled in the second one (y.log = TRUE) 2 This isn't a bioinformatics question, but it's quicker to answer than to close. df1 <- read.table(text = " AA 4 AA 6 BB 6 AB 5 BA 4 AA 3 NN 2 AN 6 NN 5 AN 4 NA 3 BB 6 BN 5 NB 1 BN 7", na.strings = "") library(ggplot2) ggplot(df1, aes(x = V1, y = V2)) + geom_bar(stat = "identity") 2 This happens because the violin plots are combined using cowplot::plot_grid before being returned by VlnPlot. You can prevent the plots from being combined by setting combine=FALSE, then modify each one by adding a boxplot, then combine the modified plots using Seurat::CombinePlots. However, the combine argument is currently broken in VlnPlot. I have pushed ... 2 The vioplot package comes built in with boxplots. You can download it from CRAN or there are more features (including formula input and separate colours) in the development version on GitHub: https://github.com/TomKellyGenetics/vioplot devtools::install_github(“TomKellyGenetics/vioplot”) library(“vioplot”) vioplot(pbmc_small@dr@pca[,1]~pbmc_small@meta.data$...

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

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