ShellyCoder / cellcall

inferring cell-cell communication from scRNA-seq of ligand-receptor
73 stars 20 forks source link

Error when using Viewintercircos #7

Closed millersan closed 2 years ago

millersan commented 3 years ago

I have met this error when I follow the pipeline using data from Seurat.

Error in if (any(factors == "")) { : 
  missing value where TRUE/FALSE needed
Calls: ViewInterCircos -> circos.initialize
Execution halted
ShellyCoder commented 3 years ago

Hi millersan,

The input data may conflict with the circlize R package. Could you upload the data object@data[[slot]] and all your parameters in the function ViewInterCircos?

Sincerely, Shelly

millersan commented 3 years ago

Dear author, thank you for your reply.

The data was normalization by SCtransform, and the parameters are as follows

H <- CreateObject_fromSeurat(Seurat.object=H, 
                                slot="data", 
                                cell_type="new",
                                data_source="CPM",
                                Org = "Homo sapiens")

H_cellcall <- TransCommuProfile(object = H,
                        pValueCor = 0.05,
                        CorValue = 0.1,
                        topTargetCor=1,
                        p.adjust = 0.05,
                        use.type="median",
                        probs = 0.9,
                        method="weighted",
                        IS_core = TRUE,
                        Org = 'Homo sapiens')
n <- H_cellcall@data$expr_l_r_log2_scale

pathway.hyper.list <- lapply(colnames(n), function(i){
    print(i)
    tmp <- getHyperPathway(data = n, object = H_cellcall, cella_cellb = i, Org="Homo sapiens")
    return(tmp)
})
myPub.df <- getForBubble(pathway.hyper.list, cella_cellb=colnames(n))
p <- plotBubble(myPub.df)
ggsave("H_bubble_pathway.pdf",p,width=20,height=15)

cell_color <- data.frame(color=c("#1F77B4B2","#FF7F0EB2","#2CA02CB2","#D62728B2","#9467BDB2","#8C564BB2"), stringsAsFactors = FALSE)
rownames(cell_color) <- c("cluster0","cluster1","cluster2","cluster3","cluster4","cluster5")

p <-ViewInterCircos(object = H_cellcall, font = 2, cellColor = cell_color, 
                lrColor = c("#F16B6F", "#84B1ED"),
                arr.type = "big.arrow",arr.length = 0.04,
                trackhight1 = 0.05, slot="expr_l_r_log2_scale",
               linkcolor.from.sender = TRUE,
                linkcolor = NULL, gap.degree = 2,
                order.vector=c("cluster_0","cluster_1","cluster_2","cluster_3","cluster_4","cluster_5"),
                trackhight2 = 0.032, track.margin2 = c(0.01,0.12), DIY = FALSE)             

ggsave("H_circos_call.pdf",p,width=8,height=10)
ShellyCoder commented 3 years ago

Ah, I see. Can you send me the full data of H_cellcall, to biocoder1024@hotmail.com? Third party package circlize was enclosed, since I'm not quite sure without the demo data.

Appreciate for your valuable response.

millersan commented 3 years ago

Dear author, I tried to downsample, but the data is still very large, sorry I may have difficulty emailing you. By the way, I tried to observe the difference between the H data and the example data, and I found some differences in it.

Example data image Example cellcall data image

My data image My data turn to cellcall data image

ShellyCoder commented 3 years ago

Hi, millersan,

Your file dd_SCT.csv in email was downloaded and processed locally.

I guess that the parameterorder.vector in function ViewInterCircosshould be c("P1", "P3", "P5", "P7", "D1", "D3", "D5", "D7") which represented your cell type stored in H_cellcall@meta.data$celltype and the colnames of H_cellcall@data$expr_l_r_log2_scale instead of c("cluster_0","cluster_1","cluster_2","cluster_3","cluster_4","cluster_5").

p <-ViewInterCircos(object = H_cellcall, font = 2, cellColor = cell_color, lrColor = c("#F16B6F", "#84B1ED"), arr.type = "big.arrow",arr.length = 0.04, trackhight1 = 0.05, slot="expr_l_r_log2_scale", linkcolor.from.sender = TRUE, linkcolor = NULL, gap.degree = 2, order.vector=c("cluster_0","cluster_1","cluster_2","cluster_3","cluster_4","cluster_5"), trackhight2 = 0.032, track.margin2 = c(0.01,0.12), DIY = FALSE)

And the figure run from my local environment has been attached.

best wishes. Shelly.

image

millersan commented 3 years ago

Dear author, thank you for your reply. I entered the metadata of cluster1-5 in cell_type, and I changed the Idents to "new" before I entered it. c("P1", "P3", "P5", "P7", "D1", "D3", "D5", "D7") is the name used in the merge in seurat. So in the heat map, the LR-pathway is the information used in the "new", not the P/D.

ShellyCoder commented 3 years ago

Ah, not familar with your data. But i'm convinced that it also work on your settings, too.

Considering some personal changes by yourself, why not open DIY and just plot circle with the result dataframe?

Set DIY = TRUE and object = yourDF in the function as the below code. And keep the colnames of yourDF in the line with order.vector. For example, if your order.vector = c('A', 'B'), the colnames of yourDF should be total or subclass of { A-B, A-A, B-A, B-B }.

yourDF <- H_cellcall@data$expr_l_r_log2_scale

ViewInterCircos(object = yourDF, font = 2, cellColor = cell_color, lrColor = c("#F16B6F", "#84B1ED"), arr.type = "big.arrow",arr.length = 0.04, trackhight1 = 0.05, slot="expr_l_r_log2_scale", linkcolor.from.sender = TRUE, linkcolor = NULL, gap.degree = 2, order.vector=c("cluster_0","cluster_1","cluster_2","cluster_3","cluster_4","cluster_5"), trackhight2 = 0.032, track.margin2 = c(0.01,0.12), DIY = TRUE)

Yours sincerely, Shelly

millersan commented 3 years ago

Dear author, Following your instructions, I successfully got the graphics, thanks a lot!

ShellyCoder commented 2 years ago

Happy for your valuable response and great appreciations ! Shelly.