iTALK icon indicating copy to clipboard operation
iTALK copied to clipboard

Potential error in FindLR for datatype = 'DEG' ?

Open dlmatera opened this issue 4 years ago • 14 comments

Cool package and useful LR pair database!

I can successfully use the FindLR function, etc. for count data but when I input a list of DEGs for various cell types the result is always returned as "No significant pairs found" - even though I can clearly see LR pairs in the data

Capture italk

Im just using the sample code with the following setup (data1 is seen above) Capture italk2

any advice?

dlmatera avatar May 14 '20 17:05 dlmatera

I got the error here LRPlot(res,datatype='DEG') Error: order should contain names of all sectors. In addition: Warning message: Since you have set order, you should better set grid.col as a named vector where sector names are the vector names (should contain all sectors).

XiaofeiSunUCSF avatar Jul 13 '20 23:07 XiaofeiSunUCSF

I got the error here LRPlot(res,datatype='DEG') Error: order should contain names of all sectors. In addition: Warning message: Since you have set order, you should better set grid.col as a named vector where sector names are the vector names (should contain all sectors).

XiaofeiSunUCSF, I've got the same problem. Can you please show detailed code of the solution? Thanks!!!

XinYu-pumch avatar Jul 16 '20 07:07 XinYu-pumch

chordDiagram

Hi XinYu-pumch, That works!!

Thank you for sharing your code!

XiaofeiSunUCSF avatar Jul 16 '20 18:07 XiaofeiSunUCSF

chordDiagram

Hi XinYu-pumch, That works!!

Thank you for sharing your code!

Hey dude!!!!! I finally sovled the problem!!!!!!!! My previous reply that Setting "order =Null" was totally wrong. We do need correct set of "order" in the function "chordDiagram".

The bug results from "order = paste(names(genes),genes)" in the function "chordDiagram". It's because the object "genes" doesn't contain the correct name of the data.frame the chordDiagram use. But it's easy to solve it just by simplely creating a new object of "genes". Here's my code:

cell_group <- unique(c(data$cell_from, data$cell_to)) genes_2 <- c(structure(cbind(paste(data$cell_from, data$ligand)), names =data$cell_from ), structure(cbind(paste(data$cell_to, data$receptor)), names = data$cell_to )) genes_2 <- genes_2[!duplicated(paste(names(genes_2), genes_2))] genes_2 <- genes_2[order(names(genes_2))] genes_matrix <- data.frame(names=names(genes_2),genes_2=genes_2) genes_matrix <- separate(genes_matrix,genes_2,into = c("cell","gene"),sep = " ") genes_matrix$genes_2 <- genes_2

And in the function "chordDiagram", "circos.trackPlotRegion" and "highlight.sector", which are in the last three parts of the code of "LRplot" function in "iTALK", you can replase the corresponding parameters by the created object "genes_matrix" to get the correct circos plot.

For detailed information, please view my codes: https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot When you've got your object "res" as the tutorial points, just run my codes and you'll get the plot.

It seems that the link has sth wrong. just paste the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" in your chrome and you'll get the code.

XinYu-pumch avatar Jul 17 '20 11:07 XinYu-pumch

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below.

deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list)

res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),]

Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

XinYu-pumch avatar Jul 17 '20 12:07 XinYu-pumch

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below.

deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list)

res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),]

Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

I got some error. I can get the plot, though. Here is the error I got.

Error: chr contains index that does not beling to available sectors. In addition: Warning messages: 1: Expected 2 pieces. Additional pieces discarded in 40 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...]. 2: 'gap.degree' can only be modified before circos.initialize, or maybe you forgot to call circos.clear in your last plot.

XiaofeiSunUCSF avatar Jul 17 '20 17:07 XiaofeiSunUCSF

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below.

deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list)

res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),]

Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Forget my last message. I figured it out finally. BTW, I like your github repositories!

XiaofeiSunUCSF avatar Jul 17 '20 18:07 XiaofeiSunUCSF

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below. deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list) res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),] Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Forget my last message. I figured it out finally. BTW, I like your github repositories!

It's my pleasure that my code can help you.

The plots will be totally different when you set different "order". If you set "order = NULL", you will find that the arrows in the circos plot may point to the wrong targets. You can try different "res" to get the results, and you will find that it's just coincidence that there is no diffenence between "order = NULL" and "order=genes_matrix$genes_2".

We can discuss if you have other problems :)

(But I cannot reply as soon as possible due to different time zones. It's Beijing time zone here and now I'm going to sleep ......

XinYu-pumch avatar Jul 17 '20 18:07 XinYu-pumch

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below.

deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list)

res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),]

Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Have you tried "cell_col=" function? I just curious why the cell color disappeared(cell color, not gene color) after I assign colors to "cell_col=" ?

XiaofeiSunUCSF avatar Jul 17 '20 18:07 XiaofeiSunUCSF

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below. deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list) res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),] Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Forget my last message. I figured it out finally. BTW, I like your github repositories!

It's my pleasure that my code can help you.

The plots will be totally different when you set different "order". If you set "order = NULL", you will find that the arrows in the circos plot may point to the wrong targets. You can try different "res" to get the results, and you will find that it's just coincidence that there is no diffenence between "order = NULL" and "order=genes_matrix$genes_2".

We can discuss if you have other problems :)

(But I cannot reply as soon as possible due to different time zones. It's Beijing time zone here and now I'm going to sleep ......

Yes, I also realized the wrong arrow pointing to. Thank you for your help! I guess it's already 3am in Beijing....You work so hard

XiaofeiSunUCSF avatar Jul 17 '20 19:07 XiaofeiSunUCSF

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below. deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list) res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),] Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Forget my last message. I figured it out finally. BTW, I like your github repositories!

It's my pleasure that my code can help you. The plots will be totally different when you set different "order". If you set "order = NULL", you will find that the arrows in the circos plot may point to the wrong targets. You can try different "res" to get the results, and you will find that it's just coincidence that there is no diffenence between "order = NULL" and "order=genes_matrix$genes_2". We can discuss if you have other problems :) (But I cannot reply as soon as possible due to different time zones. It's Beijing time zone here and now I'm going to sleep ......

Yes, I also realized the wrong arrow pointing to. Thank you for your help! I guess it's already 3am in Beijing....You work so hard

I've found another way to get the circos plot with appropriate colors. The codes are based on https://www.jianshu.com/p/b589bc23d7a0. You can find the code in “https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat%E4%B8%8B%E6%B8%B8%E5%88%86%E6%9E%90/iTALK%E7%9A%84res%E7%BB%98%E5%9B%BE%EF%BC%9Acircos%20plot” When you get your "res" object, just run the code.

XinYu-pumch avatar Jul 19 '20 15:07 XinYu-pumch

Reply to dlmatera: If you want to find the pairs in all of your cell types, just run my code below. deg_list=list() for (cell in unique(iTalk_data$cell_type)) { t <- DEG(iTalk_data %>% filter(cell_type==cell),method='DESeq2',contrast=c('BD', 'HC')) deg_list[[cell]]=t } deglist=do.call(rbind,deg_list) res<-NULL for(comm_type in comm_list){ res_cat<-FindLR(deglist, datatype='DEG',comm_type=comm_type) #res_cat<-FindLR(deg_t, datatype='DEG',comm_type=comm_type) res<-rbind(res,res_cat) } res <- na.omit(res) res<-res[order(abs(res$cell_from_logFC*res$cell_to_logFC),decreasing=T),] Then use the code in the "https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat下游分析/iTALK-LRplot" to get the circos plot.

Forget my last message. I figured it out finally. BTW, I like your github repositories!

It's my pleasure that my code can help you. The plots will be totally different when you set different "order". If you set "order = NULL", you will find that the arrows in the circos plot may point to the wrong targets. You can try different "res" to get the results, and you will find that it's just coincidence that there is no diffenence between "order = NULL" and "order=genes_matrix$genes_2". We can discuss if you have other problems :) (But I cannot reply as soon as possible due to different time zones. It's Beijing time zone here and now I'm going to sleep ......

Yes, I also realized the wrong arrow pointing to. Thank you for your help! I guess it's already 3am in Beijing....You work so hard

I've found another way to get the circos plot with appropriate colors. The codes are based on https://www.jianshu.com/p/b589bc23d7a0. You can find the code in “https://github.com/XinYu-pumch/bioinformatics/blob/master/seurat%E4%B8%8B%E6%B8%B8%E5%88%86%E6%9E%90/iTALK%E7%9A%84res%E7%BB%98%E5%9B%BE%EF%BC%9Acircos%20plot” When you get your "res" object, just run the code.

Great! Thank you!

XiaofeiSunUCSF avatar Jul 20 '20 22:07 XiaofeiSunUCSF

Well, I think you have missed some items in your raw data. The circosplot has many layers, in the inner of which lie the genes. Because a receptor can match many ligands, and vice versa, we need different kinds of colors to distinguish them. However, there should be an layer outside the inner layer, which consists of "L" and "R" with relevant colors. It's one of the primary steps to make a circosplot. I think that's what you are referring to, yet it's not shown in your pic. So I think there is sth missing in your raw table. Can you send me a demo of your raw table if it's convenient? Perhaps I can add some lines of codes.

Jack Zhang [email protected] 于2020年12月15日周二 上午8:59写道:

@XinYu-pumch https://github.com/XinYu-pumch Hey dude, thanks U code for us, however I find a new error. [image: image] https://user-images.githubusercontent.com/51999214/102153976-5f11c400-3eb3-11eb-8952-a591af92fb6c.png

As you can see, the genes come in many colors, but the correct setup is to have two, one is ligand other is receptor.Due to my poor ability to read code, I was unable to solve it, although it did not seem to be a big problem. Thanks again.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Coolgenome/iTALK/issues/19#issuecomment-744925966, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO354E5OSUNRQIWEESFV6ATSU2YIJANCNFSM4NA34ARA .

XinYu-pumch avatar Dec 15 '20 01:12 XinYu-pumch

#17

liaoshengyou avatar Feb 18 '21 13:02 liaoshengyou