Closed Zymeth0211 closed 8 months ago
Please provide the code and input files to run the plots in this figure. Without knowing what code you are writing, it is impossible to give an adequate answer.
Dear Moshi4 and team
I am sorry for the trouble Here is my code:
from pycirclize import Circos
import pandas as pd
import math
col_names = ["J2", "J3", "J4", "J6", "J7"]
row_names = ["V3-1", "V3-2", "V3-3", "V3S1", "V3S25", "V3S28", "V3S31", "V3S32", "V3S33", "V3S39", "V3S41", "V3S53", "V3S58", "V3S60", "V3S61", "V3S63", "V3S65", "V3S66"]
matrix_data = [
[0,0,1,0,0],
[0,0,0,2,0],
[0,0,249,13,3],
[1,0,0,1,0],
[0,0,0,0,1],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,2,0,0],
[0,1,5,2,1],
[1,0,44,9,2],
[0,0,1,0,0],
[0,0,1,1,0],
[0,0,28,7,7],
[0,0,1,0,0],
[1,0,51,6,40],
[1,0,9,3,2],
]
matrix_df = pd.DataFrame(matrix_data, index=row_names, columns=col_names)
circos = Circos.initialize_from_matrix(
matrix_df,
start=-90,
end=240,
space=3,
endspace= True,
r_lim=(93, 100),
cmap="viridis",
ticks_interval=20,
label_kws=dict(r=110, size=8, color="black"),
)
circos.text("Top 500 sequences of VHH TfR 0R \n VJ region link map", r=100 * math.sqrt(2), deg=315, size =10)
print(matrix_df)`
Code Example
from pycirclize import Circos
from pycirclize.utils import calc_group_spaces
import pandas as pd
import math
col_names = ["J2", "J3", "J4", "J6", "J7"]
row_names = ["V3-1", "V3-2", "V3-3", "V3S1", "V3S25", "V3S28", "V3S31", "V3S32", "V3S33", "V3S39", "V3S41", "V3S53", "V3S58", "V3S60", "V3S61", "V3S63", "V3S65", "V3S66"]
matrix_data = [
[0,0,1,0,0],
[0,0,0,2,0],
[0,0,249,13,3],
[1,0,0,1,0],
[0,0,0,0,1],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,2,0,0],
[0,1,5,2,1],
[1,0,44,9,2],
[0,0,1,0,0],
[0,0,1,1,0],
[0,0,28,7,7],
[0,0,1,0,0],
[1,0,51,6,40],
[1,0,9,3,2],
]
matrix_df = pd.DataFrame(matrix_data, index=row_names, columns=col_names)
# Calculate group spaces to separate V & J groups
groups = [len(row_names), len(col_names)]
spaces = calc_group_spaces(groups, space_bw_group=20, space_in_group=3)
circos = Circos.initialize_from_matrix(
matrix_df,
start=-90,
end=270,
space=spaces,
endspace= True,
r_lim=(93, 100),
# Set dict cmap
cmap={"V3-3": "red", "V3S41": "blue", "V3S53": "lime", "V3S61": "orange", "V3S65": "purple", "V3S66": "pink"},
ticks_interval=20,
# Set orientation of labels
label_kws=dict(r=110, size=8, color="black", orientation="vertical"),
)
# Set fontweight="bold"
circos.text("Top 500 sequences of VHH TfR 0R \n VJ region link map", r=100 * math.sqrt(2), deg=315, size=10, fontweight="bold")
circos.savefig("example.png")
example.png
Thank you so much mr. Moshi04.
It is so helpful for me. I would like to ask about matrix data from the import file. If I have this matrix file in csv, what code do we need to insert this csv file to the previous code? 0R Matrix.csv.
and another question about grouping. According to your code: groups = [len(row_names), len(col_names)]
When I learned from your lesson code of "plot_tips.ipynb", you used this code group1, group2, group3 = list("ABCD"), list("EFG"), list("HIJ") with "list" on it. So, what is the difference?
Once again, thank you in advance and I am sorry for the trouble.
Code Example
from pycirclize import Circos
from pycirclize.utils import calc_group_spaces
import pandas as pd
import math
# Read matrix csv
matrix_df = pd.read_csv("0R.Matrix.csv", index_col=0)
# Calculate group spaces to separate V & J groups
groups = [len(matrix_df.index), len(matrix_df.columns)]
spaces = calc_group_spaces(groups, space_bw_group=20, space_in_group=3)
circos = Circos.initialize_from_matrix(
matrix_df,
start=-90,
end=270,
space=spaces,
endspace= True,
r_lim=(93, 100),
# Set dict cmap
cmap={"V3-3": "red", "V3S41": "blue", "V3S53": "lime", "V3S61": "orange", "V3S65": "purple", "V3S66": "pink"},
ticks_interval=20,
# Set orientation of labels
label_kws=dict(r=110, size=8, color="black", orientation="vertical"),
)
# Set fontweight="bold"
circos.text("Top 500 sequences of VHH TfR 0R \n VJ region link map", r=100 * math.sqrt(2), deg=315, size=10, fontweight="bold")
circos.savefig("example.png")
The other question about groups is difficult to answer because I don't understand what is being asked.It seems to me that this is due to a lack of understanding of Python syntax, so please interpret the purpose of the code yourself.
Thank you so much for your comment. I completely understand.
Best regards.
Dear Mr. Moshi04.
I sincerely apologize for reopening the issue. I have another question. I am trying to separate into three groups: V3, V3S, and J groups and I tried to use this code:
from pycirclize import Circos
from pycirclize.utils import calc_group_spaces
import pandas as pd
import math
col_names = ["J2", "J3", "J4", "J6", "J7"]
row_names = ["V3-1", "V3-2", "V3-3", "V3S1", "V3S25", "V3S28", "V3S31", "V3S32", "V3S33", "V3S39", "V3S41", "V3S53", "V3S58", "V3S60", "V3S61", "V3S63", "V3S65", "V3S66"]
matrix_data = [
[0,0,1,0,0],
[0,0,0,2,0],
[0,0,249,13,3],
[1,0,0,1,0],
[0,0,0,0,1],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,2,0,0],
[0,1,5,2,1],
[1,0,44,9,2],
[0,0,1,0,0],
[0,0,1,1,0],
[0,0,28,7,7],
[0,0,1,0,0],
[1,0,51,6,40],
[1,0,9,3,2],
]
matrix_df = pd.DataFrame(matrix_data, index=row_names, columns=col_names)
print(matrix_df)
# Calculate group spaces to separate V3, V3S & J groups
groups = [len(row_names[0:2]), len(row_names[3:17]), len(col_names)]
spaces = calc_group_spaces(groups, space_bw_group=20, space_in_group=3)
circos = Circos.initialize_from_matrix(
matrix_df,
start=-90,
end=270,
space=spaces,
endspace= True,
r_lim=(93, 100),
# Set dict cmap
cmap={"V3-1": "red", "V3S41": "blue", "V3S53": "lime", "V3S61": "orange", "V3S65": "purple", "V3S66": "pink"},
ticks_interval=20,
# Set orientation of labels
label_kws=dict(r=110, size=8, color="black", orientation="vertical"),
link_kws=dict(hatch="//", direction=1, color="blue", alpha=0.4, lw=1),
ticks_kws=dict(outer=True, major_interval=10, label_size=10, color="black", label_orientation="vertical", show_label=True)
)
# Set fontweight="bold"
circos.text("Top 500 sequences of VHH TfR 0R \n VJ region link map", r=100 * math.sqrt(2), deg=315, size=10, fontweight="bold")
But I got an error code. Would you mind suggesting the example code?
and, I am also trying ticks_kws code, but when I tried to modify ticks_kws, hoping I could show major and minor interval. However, the ticks were not shown. Could you show me the way to use it.
I feel that many of the questions are due to a lack of basic understanding of Python. I don't want to be asked endless basic questions, so I apologize, but this will be my last answer.
Code Example
from pycirclize import Circos
from pycirclize.utils import calc_group_spaces
import pandas as pd
import math
col_names = ["J2", "J3", "J4", "J6", "J7"]
row_names = ["V3-1", "V3-2", "V3-3", "V3S1", "V3S25", "V3S28", "V3S31", "V3S32", "V3S33", "V3S39", "V3S41", "V3S53", "V3S58", "V3S60", "V3S61", "V3S63", "V3S65", "V3S66"]
matrix_data = [
[0,0,1,0,0],
[0,0,0,2,0],
[0,0,249,13,3],
[1,0,0,1,0],
[0,0,0,0,1],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,1,0,0],
[0,0,2,0,0],
[0,1,5,2,1],
[1,0,44,9,2],
[0,0,1,0,0],
[0,0,1,1,0],
[0,0,28,7,7],
[0,0,1,0,0],
[1,0,51,6,40],
[1,0,9,3,2],
]
matrix_df = pd.DataFrame(matrix_data, index=row_names, columns=col_names)
# Calculate group spaces to separate V3, V3S & J groups
groups = [len(row_names[0:3]), len(row_names[3:18]), len(col_names)]
spaces = calc_group_spaces(groups, space_bw_group=20, space_in_group=3)
circos = Circos.initialize_from_matrix(
matrix_df,
start=-90,
end=270,
space=spaces,
endspace= True,
r_lim=(93, 100),
# Set dict cmap
cmap={"V3-1": "red", "V3S41": "blue", "V3S53": "lime", "V3S61": "orange", "V3S65": "purple", "V3S66": "pink"},
# Set orientation of labels
label_kws=dict(r=110, size=8, color="black", orientation="vertical"),
)
# Plot xticks manually
for sector in circos.sectors:
track = sector.tracks[0]
major_interval, minor_interval = 50, 10
if track.size >= major_interval:
track.xticks_by_interval(major_interval)
track.xticks_by_interval(minor_interval, tick_length=1, show_label=False)
# Set fontweight="bold"
circos.text("Top 500 sequences of VHH TfR 0R \n VJ region link map", r=100 * math.sqrt(2), deg=315, size=10, fontweight="bold")
circos.savefig("example.png")
example.png
Dear Mr. Moshi04
Thank you so much for your generous help.
Dear Mr. Moshi4 and team,
Thank you for your help in the previous discussion.
I would like to ask about some modifications to my picture. I really apologize for the many questions at this time.
Thank you so much for your help, I learned a lot about Python from your pycirclize. Best regards,