Commit adbf30f6 authored by HaojiaWu's avatar HaojiaWu
Browse files

Readme updated

parent 2c74381e
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#'
#' @param seu_obj A complete Seurat object
#' @param feature Gene name. Only one gene is allowed.
#' @param celltypes Cell types to be included in the dot plot. Default: all cell types.
#' @param groupby The group to show on x axis. One of the column names in meta.data.
#' @param splitby The group to separate the gene expression. One of the column names in meta.data.
#' @param scale.by Methods to scale the dot size. "radius" or "size"
@@ -18,6 +19,7 @@
complex_dotplot_single <- function(
  seu_obj, 
  feature, 
  celltypes=NULL,
  groupby,
  splitby=NULL,
  strip.color=NULL,
@@ -30,7 +32,10 @@ complex_dotplot_single <- function(
    seu_obj@meta.data[,groupby] <-factor(seu_obj@meta.data[,groupby], levels = names(table(seu_obj@meta.data[,groupby])))
  }
  levels(seu_obj)<-rev(levels(seu_obj))
  if(is.null(celltypes)){
    celltypes<-levels(seu_obj)
  }
  seu_obj<-subset(seu_obj,idents=celltypes)
  celltypes<-gsub("_", "-", celltypes)
  seu_obj@meta.data$celltype<-as.character(seu_obj@active.ident)
  seu_obj@meta.data$celltype<-gsub("_", "-", seu_obj@meta.data$celltype)
@@ -117,6 +122,7 @@ complex_dotplot_single <- function(
#'
#' @param seu_obj A complete Seurat object
#' @param features A vector of gene names.
#' @param celltypes Cell types to be included in the dot plot. Default: all cell types.
#' @param groupby Group ID Must be one of the column names in the meta.data slot of the Seurat object.
#' @param strip.color Colors for the strip background
#' @return A ggplot object
@@ -124,17 +130,17 @@ complex_dotplot_single <- function(
complex_dotplot_multiple <- function(
  seu_obj, 
  features, 
  celltypes=NULL,
  groupby, 
  strip.color = NULL
  ){
 pb <- progress_bar$new(
   format = "  Ploting [:bar] :percent eta: :eta",
   clear = FALSE, total = length(features), width = 100)
 features=rev(features)
 plot_list<-list()
 for(i in 1:length(features)){
  pp<-invisible(
    complex_dotplot_single(seu_obj = seu_obj, feature = features[i], groupby = groupby)
    complex_dotplot_single(seu_obj = seu_obj, feature = features[i], groupby = groupby, celltypes = celltypes)
  )
  pp<-pp$data
  pp$gene <- features[i]
@@ -143,6 +149,7 @@ complex_dotplot_multiple <- function(
  Sys.sleep(1 / length(features))
  }
  all_data<-do.call('rbind', plot_list)
  all_data$gene<-factor(all_data$gene, levels = rev(features)) 
  all_data$celltype <- factor(all_data$celltype, levels = levels(seu_obj))
  p <- invisible(
    ggplot(all_data, aes(x = groupby, y = gene)) +  
+13 −3

File changed.

Preview size limit exceeded, changes collapsed.

+16 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ set.seed(1234)
cluster_colors<-rand_color(length(levels(iri.integrated)))
group_colors<-rand_color(length(table(iri.integrated$Group)))
rep_colors<-group_colors<-rand_color(length(table(iri.integrated$orig.ident)))

###plot and save figures
png(filename =  'circlize_plot.png', width = 6, height = 6,units = 'in', res = 300)
plot_circlize(circ_data,do.label = T, pt.size = 0.01, col.use = cluster_colors ,bg.color = 'white', kde2d.n = 200)
@@ -40,8 +41,22 @@ dev.off()
![alt text](https://github.com/HaojiaWu/Plot1cell/blob/master/circlize_plot.png) <br />

### 2. Dotplot to show gene expression across groups
Here is an example to use plot1cell to show one gene expression across different cell types breakdown by group.
```
png(filename =  'dotplot_single.png', width = 4, height = 6,units = 'in', res = 300)
complex_dotplot_single(seu_obj = iri.integrated, feature = "Havcr1",groupby = "Group")
dev.off()
```
![alt text](https://github.com/HaojiaWu/Plot1cell/blob/master/dotplot_single.png) <br />
plot1cell allows visualization of multiple genes in dotplot format too. Here is an example.
```
png(filename =  'dotplot_multiple.png', width = 10, height = 4,units = 'in', res = 300)
complex_dotplot_multiple(seu_obj = iri.integrated, features = c("Slc34a1","Slc7a13","Havcr1","Krt20","Vcam1"),groupby = "Group", celltypes = c("PTS1" ,   "PTS2"  ,  "PTS3"  ,  "NewPT1" , "NewPT2"))
dev.off()
```
![alt text](https://github.com/HaojiaWu/Plot1cell/blob/master/dotplot_multiple.png) <br />


### 3. Vlnplot to show gene expression across groups



dotplot_multiple.png

0 → 100644
+252 KiB
Loading image diff...

dotplot_single.png

0 → 100644
+205 KiB
Loading image diff...
Loading