Download data here. For how to construct the data objects, see Tutorial.

Quick facts about the datasets:


Load library and data.

library(FRmatch)
load("sce-M1.rda")
load("sce-MTG.rda")

Take a look at the gene expression data distribution. For the SSv4 data, we followed the standard preprocessing of SMART-seq data by taking the logCPM of the raw count data, which was stored in the @assays$logcounts slot of the data object. Since both datasets are generated using the same experimental platform and follow similar distribution, no normalization is needed.

par(mfrow=c(1,2))
hist(rowMedians(logcounts(sce.M1)))
hist(rowMedians(logcounts(sce.MTG)))

Take an overview of the cell type clusters in both datasets. Only cells with cluster labels are used, i.e. removed cells without label from the original publication.

## plot cluster size
plot_clusterSize(sce.M1, sce.MTG, name.E1 = "M1", name.E2 = "MTG")

The following codes are suggested to plot all cell type barcode plots in an assigned folder. NOT RUN HERE.

## barcode plots
clusters.M1 <- unique(colData(sce.M1)$cluster_membership)
clusters.MTG <- unique(colData(sce.ref75)$cluster_membership)

## by M1 markers
common.markers.M1 <- intersect(unique(sce.M1@metadata$cluster_marker_info$markerGene), rownames(sce.ref75))
for (cl in clusters.MTG){
  plot_cluster_by_markers(sce.M1, sce.ref75, cluster.name = cl,
                          name.E2 = "MTG.", 
                          filename = paste0("plot_barcode_M1_markers/MTG_",cl,".pdf"))
}
for (cl in clusters.M1){
  plot_cluster_by_markers(sce.M1[common.markers.M1,], cluster.name = cl,
                          name.E1 = "M1.",
                          filename = paste0("plot_barcode_M1_markers/M1_",cl,".pdf"))
}

## by MTG markers
common.markers.MTG <- intersect(unique(sce.ref75@metadata$cluster_marker_info$markerGene), rownames(sce.M1))
for (cl in clusters.M1){
  plot_cluster_by_markers(sce.ref75, sce.M1, cluster.name = cl,
                          name.E2 = "M1.",
                          filename = paste0("plot_barcode_MTG_markers/M1_",cl,".pdf"))
}
for (cl in clusters.MTG){
  plot_cluster_by_markers(sce.ref75[common.markers.MTG,], cluster.name = cl,
                          name.E1 = "MTG.",
                          filename = paste0("plot_barcode_MTG_markers/MTG_",cl,".pdf"))
}

Run FR-Match

One direction.

##--------------------------##
## M1 (query) --> MTG (ref) ##
##--------------------------##
rst.M1toMTG <- FRmatch(sce.query=sce.M1, sce.ref=sce.MTG, prefix=c("M1.","MTG."),
                       filter.size=5, subsamp.size=20) #filter.size=5 is a placeholder, all clusters are used

The other direction.

##--------------------------##
## MTG (query) --> M1 (ref) ##
##--------------------------##
rst.MTGtoM1 <- FRmatch(sce.query=sce.MTG, sce.ref=sce.M1, prefix=c("MTG.","M1."),
                       filter.size=5, subsamp.size=20) #filter.size=5 is a placeholder, all clusters are used

Combined plot of the bi-directional FR-Match results, showing two-way matches only.

plot_bi_FRmatch(rst.M1toMTG, rst.MTGtoM1, name.E1="M1.", name.E2="MTG.", two.way.only=TRUE)


Some one-directional results

M1 (query) to MTG (reference)

plot_FRmatch(rst.M1toMTG, main="M1 to MTG")

plot_FRmatch(rst.M1toMTG, type="padj")

## top match
predict_most_similar_cluster(rst.M1toMTG)

MTG (query) to M1 (reference)

plot_FRmatch(rst.MTGtoM1, main="MTG to M1")

plot_FRmatch(rst.MTGtoM1, type="padj")

## top match
predict_most_similar_cluster(rst.MTGtoM1)

The full bi-directional plot

plot_bi_FRmatch(rst.M1toMTG, rst.MTGtoM1, name.E1="M1.", name.E2="MTG.")

LS0tCnRpdGxlOiAiQ2VsbCB0eXBlIG1hdGNoaW5nIGFjcm9zcyBub24tb3ZlcmxhcHBpbmcgbmV1cm9hbmF0b21pY2FsIHJlZ2lvbnMgLSBNMSBhbmQgTVRHIgpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKYXV0aG9yOiAiWXVuIChSZW5lZSkgWmhhbmcsIHpoYW5neUBqY3ZpLm9yZyIKZGF0ZTogImByIGZvcm1hdChTeXMudGltZSgpLCAnJUIgJWQsICVZJylgIgotLS0KCgpgYGB7ciwgaW5jbHVkZSA9IEZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoY2FjaGUgPSBUUlVFKQpzZXR3ZCgifi9Eb2N1bWVudHMvQ1pJLTIwMTgvQW5hbHlzZXNfRlJtYXRj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