Skip to content

Commit c171a7d

Browse files
committed
Support female haploid chromosome representation
1 parent c18fc23 commit c171a7d

5 files changed

Lines changed: 54 additions & 18 deletions

File tree

dist/js/ideogram.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,7 +1898,11 @@ Ideogram.prototype.drawChromosomeLabels = function() {
18981898
lines = d.name.match(/^(.*)\s+([^\s]+)$/).slice(1).reverse();
18991899
}
19001900

1901-
if ('sex' in ideo.config && i === ideo.sexChromosomes.index) {
1901+
if (
1902+
'sex' in ideo.config &&
1903+
ideo.config.ploidy === 2 &&
1904+
i === ideo.sexChromosomes.index
1905+
) {
19021906
if (ideo.config.sex === 'male') {
19031907
lines = ['XY'];
19041908
} else {
@@ -3446,10 +3450,6 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
34463450
ideo.chromosomes[taxid] = {};
34473451

34483452
ideo.setSexChromosomes(chrs);
3449-
// if ('sex' in ideo.config && ideo.config.sex === 'male') {
3450-
// chrs.splice(ideo.sexChromosomes.index, 1);
3451-
// ideo.config.chromosomes[taxid] = chrs;
3452-
// }
34533453

34543454
for (j = 0; j < chrs.length; j++) {
34553455
chromosome = chrs[j];
@@ -3461,7 +3461,13 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
34613461
ideo.chromosomes[taxid][chromosome] = chrModel;
34623462
ideo.chromosomesArray.push(chrModel);
34633463

3464-
if ('sex' in ideo.config && ideo.sexChromosomes.index + 2 === chrIndex) {
3464+
if (
3465+
'sex' in ideo.config &&
3466+
(
3467+
ideo.config.ploidy === 2 && ideo.sexChromosomes.index + 2 === chrIndex ||
3468+
ideo.config.sex === 'female' && chrModel.name === 'Y'
3469+
)
3470+
) {
34653471
continue;
34663472
}
34673473

@@ -3476,7 +3482,11 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
34763482
.attr("transform", transform)
34773483
.attr("id", chrModel.id + "-chromosome-set");
34783484

3479-
if ('sex' in ideo.config && ideo.sexChromosomes.index + 1 === chrIndex) {
3485+
if (
3486+
'sex' in ideo.config &&
3487+
ideo.config.ploidy === 2 &&
3488+
ideo.sexChromosomes.index + 1 === chrIndex
3489+
) {
34803490
ideo.drawSexChromosomes(bandsArray, taxid, container, defs, j, chrs);
34813491
continue;
34823492
}
@@ -3533,7 +3543,7 @@ Ideogram.prototype.setSexChromosomes = function(chrs) {
35333543
// https://en.wikipedia.org/wiki/Category:Sex_chromosome_aneuploidies
35343544

35353545

3536-
if (!this.config.sex) return;
3546+
if (this.config.ploidy !== 2 || !this.config.sex) return;
35373547

35383548
var ideo = this,
35393549
sexChrs = {'X': 1, 'Y': 1},

dist/js/ideogram.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/ideogram.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/core.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,11 @@ Ideogram.prototype.drawChromosomeLabels = function() {
507507
lines = d.name.match(/^(.*)\s+([^\s]+)$/).slice(1).reverse();
508508
}
509509

510-
if ('sex' in ideo.config && i === ideo.sexChromosomes.index) {
510+
if (
511+
'sex' in ideo.config &&
512+
ideo.config.ploidy === 2 &&
513+
i === ideo.sexChromosomes.index
514+
) {
511515
if (ideo.config.sex === 'male') {
512516
lines = ['XY'];
513517
} else {
@@ -2055,10 +2059,6 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
20552059
ideo.chromosomes[taxid] = {};
20562060

20572061
ideo.setSexChromosomes(chrs);
2058-
// if ('sex' in ideo.config && ideo.config.sex === 'male') {
2059-
// chrs.splice(ideo.sexChromosomes.index, 1);
2060-
// ideo.config.chromosomes[taxid] = chrs;
2061-
// }
20622062

20632063
for (j = 0; j < chrs.length; j++) {
20642064
chromosome = chrs[j];
@@ -2070,7 +2070,13 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
20702070
ideo.chromosomes[taxid][chromosome] = chrModel;
20712071
ideo.chromosomesArray.push(chrModel);
20722072

2073-
if ('sex' in ideo.config && ideo.sexChromosomes.index + 2 === chrIndex) {
2073+
if (
2074+
'sex' in ideo.config &&
2075+
(
2076+
ideo.config.ploidy === 2 && ideo.sexChromosomes.index + 2 === chrIndex ||
2077+
ideo.config.sex === 'female' && chrModel.name === 'Y'
2078+
)
2079+
) {
20742080
continue;
20752081
}
20762082

@@ -2085,7 +2091,11 @@ Ideogram.prototype.initDrawChromosomes = function(bandsArray) {
20852091
.attr("transform", transform)
20862092
.attr("id", chrModel.id + "-chromosome-set");
20872093

2088-
if ('sex' in ideo.config && ideo.sexChromosomes.index + 1 === chrIndex) {
2094+
if (
2095+
'sex' in ideo.config &&
2096+
ideo.config.ploidy === 2 &&
2097+
ideo.sexChromosomes.index + 1 === chrIndex
2098+
) {
20892099
ideo.drawSexChromosomes(bandsArray, taxid, container, defs, j, chrs);
20902100
continue;
20912101
}
@@ -2142,7 +2152,7 @@ Ideogram.prototype.setSexChromosomes = function(chrs) {
21422152
// https://en.wikipedia.org/wiki/Category:Sex_chromosome_aneuploidies
21432153

21442154

2145-
if (!this.config.sex) return;
2155+
if (this.config.ploidy !== 2 || !this.config.sex) return;
21462156

21472157
var ideo = this,
21482158
sexChrs = {'X': 1, 'Y': 1},

test/web-test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,22 @@ describe("Ideogram", function() {
785785
var ideogram = new Ideogram(config);
786786
});
787787

788+
it("should omit Y chromosome in haploid human female", function(done) {
789+
790+
function callback() {
791+
var hasChrY = d3.selectAll('#chrY-9606').nodes().length >= 1;
792+
assert.isFalse(hasChrY);
793+
done();
794+
}
795+
796+
var config = {
797+
organism: "human",
798+
sex: "female"
799+
};
800+
config.onLoad = callback;
801+
var ideogram = new Ideogram(config);
802+
});
803+
788804
// it("should align chr. label with band-labeled vertical chromosome", function(done) {
789805
// // Tests use case from ../examples/human.html
790806
//

0 commit comments

Comments
 (0)