Commit fb74885d authored by Guangchuang Yu's avatar Guangchuang Yu
Browse files

fixed small issues

parent 10ba06b8
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+1 −0
Original line number Diff line number Diff line
gh-pages
+6 −0
Original line number Diff line number Diff line
@@ -43,3 +43,9 @@ clean:
	cd ..;\
	$(RM) -r $(PKGNAME).Rcheck/

pages:
	Rscript -e 'rmarkdown::render("gh-pages/index.Rmd")'

publish:
	cd gh-pages;\
	git add .; git commit -m 'update'; git push
+7 −2
Original line number Diff line number Diff line
@@ -3,15 +3,20 @@
##' @param object Seurat object
##' @param features selected features (i.e., genes)
##' @param dims selected dimensions (must be a two-length vector) that are used in visualization
##' @param ncol number of facet columns if 'length(features) > 1'
##' @param .fun user defined function that will be applied to selected features (default is to filter out genes with no expression values)
##' @param ... additional parameters pass to 'scattermore::geom_scattermore()'
##' @return layer of points for selected features
##' @export
sc_dim_geom_feature <- function(object, features, dims = c(1,2), ..., 
sc_dim_geom_feature <- function(object, features, dims = c(1,2), ncol=3, ..., 
            .fun=function(.data) dplyr::filter(.data, .data$value > 0)) {
    d <- get_dim_data(object, dims=dims, features=features)
    d <- tidyr::pivot_longer(d, 4:ncol(d), names_to = "features")
    sc_geom_point(data = .fun(d), ...)
    d$features <- factor(d$features, levels = features)
    p <- sc_geom_point(data = .fun(d), ...)
    list(p, 
        .feature_setting(features=features, ncol=ncol)
    )
}


+14 −11
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@
##' @export
sc_feature <- function(object, features, 
                    dims=c(1,2), reduction=NULL, 
                    cells=NULL, slot = "data", mapping, ncol=3, ...) {
                    cells=NULL, slot = "data", mapping=NULL, ncol=3, ...) {
    d <- get_dim_data(object = object, features = features,
                    dims = dims, reduction = reduction, 
                    cells = cells, slot = slot)
@@ -39,23 +39,26 @@ sc_feature <- function(object, features,
        scale_color_gradient(low='grey', high='blue')           
        #scale_color_gradient2(low='blue', mid='grey', high='red') + 

    p + .feature_setting(features=features, ncol=ncol)
}


.feature_setting <- function(features, ncol) {
    if (length(features) == 1) {
        p <- p + ggtitle(features) +
        res <- list(ggtitle(features),
            theme(plot.title=element_text(size=rel(1.5), face='bold'))
        ) 
    } else {
        p <- p + facet_wrap(~features, ncol=ncol) +
            theme_bw() 
        res <- list(facet_wrap(~features, ncol=ncol),
            theme_bw(),
            theme(axis.text = element_blank(), 
                axis.title = element_blank(), 
                axis.ticks = element_blank(), 
                panel.grid = element_blank()
            )
        ) 
    }

    return(p)
    return(res)
}

## features = c("MS4A1", "GNLY", "CD3E", "CD14", "FCER1A", "FCGR3A", "LYZ", "PPBP", "CD8A")
## sc_feature(pbmc, features)

+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ sc_violin <- function(object, features,
                    mapping = NULL, ncol=3, ...) {
    d <- get_dim_data(object, dims=NULL, features=features)
    d <- tidyr::pivot_longer(d, 2:ncol(d), names_to = "features")
    d$features <- factor(d$features, levels = features)
    if (!is.null(.fun)) {
        d <- .fun(d)
    }
Loading