Commit 1f39671f authored by HaojiaWu's avatar HaojiaWu
Browse files

bug fixes

parent 3d4453a6
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -224,9 +224,18 @@ plot_circlize <- function(
#' @param data_plot Data for circlize plot 
#' @param group The group to be shown on the new track
#' @param colors Color palette to color the group
#' @param track_num Which number this track is? Value is integer and starts with 2 for the 2nd track, track_num=3 for the 3rd track, etc...
#' @return A new circlize track adding to the current circlize plot
#' @export
add_track <- function(data_plot, group, colors = NULL){
add_track <- function(
  data_plot, 
  group, 
  track_num, 
  colors = NULL
  ){
  if(track_num<2){
    stop("The first track is the cluster track. Please change the track_num to a value greater than 1")
  }
  circos.track(data_plot$Cluster, data_plot$x_polar2, y=data_plot$dim2, bg.border=NA)
  celltypes<-names(table(data_plot$Cluster))
  group_names<-names(table(data_plot[,group]))
@@ -244,4 +253,5 @@ add_track <- function(data_plot, group, colors = NULL){
    dat_seg2<-scale_factor*dat_seg2
    circos.segments(x0 = dat_seg, y0 = 0, x1 = dat_seg2, y1 = 0, col = col_group, sector.index = celltypes[i], lwd=3)
  }
  text(x = (1-0.03*(track_num-1)), y=0.1, labels = group, cex = 0.4, col = 'black',srt=-90)
}
+2 −2
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@ rep_colors<-rand_color(length(names(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, repel = T)
add_track(circ_data, group = "Group", colors = group_colors) ## can change it to one of the columns in the meta data of your seurat object
add_track(circ_data, group = "orig.ident",colors = rep_colors) ## can change it to one of the columns in the meta data of your seurat object
add_track(circ_data, group = "Group", colors = group_colors, track_num=2) ## can change it to one of the columns in the meta data of your seurat object
add_track(circ_data, group = "orig.ident",colors = rep_colors, track_num = 3) ## can change it to one of the columns in the meta data of your seurat object
dev.off()
```
![alt text](https://github.com/HaojiaWu/Plot1cell/blob/master/data/circlize_plot.png) <br />
+4.17 KiB (945 KiB)
Loading image diff...
+3 −1
Original line number Diff line number Diff line
@@ -4,13 +4,15 @@
\alias{add_track}
\title{Add tracks to the circlize plot}
\usage{
add_track(data_plot, group, colors = NULL)
add_track(data_plot, group, track_num, colors = NULL)
}
\arguments{
\item{data_plot}{Data for circlize plot}

\item{group}{The group to be shown on the new track}

\item{track_num}{Which number this track is? Value is integer and starts with 2 for the 2nd track, track_num=3 for the 3rd track, etc...}

\item{colors}{Color palette to color the group}
}
\value{