Eight years ago, Rep. Mike Castle of Delaware was headed to the U.S. Senate. Joe Biden had left his seat open upon ascending to the vice presidency, and Castle, a Republican, appeared to be in the perfect position to take it. Delaware is a solidly blue state, but Castle had built a moderate record, was well-liked and held an early lead over his three potential Democratic opponents. His only problem: That moderate record cut both ways. By September 2010, the tea party wave was cresting and Castle got swallowed up. He lost the Republican primary to tea partier Christine O’Donnell. Two months later, O’Donnell lost the general election by 17 points, and Republicans failed to win a majority in the Senate.

The Castle-O’Donnell primary should be a cautionary tale for Democrats now. Some liberal activists want to challenge Sen. Joe Manchin in West Virginia’s 2018 Democratic primary. They complain that he’s too conservative and that he voted to confirm most of President Trump’s Cabinet officials. Manchin is probably safe — Democratic voters in West Virginia are pretty conservative. But the impulse to challenge Manchin from the left could be dangerous for Democrats. Manchin, even though he often votes with the GOP, is incredibly valuable to the Democratic Party compared to any plausible alternative.

West Virginia leans heavily Republican on the federal level. Trump won it by 42 percentage points in 2016. Republican Shelley Moore Capito easily dispatched — by 28 percentage points — Democrat Natalie Tennant in the 2014 U.S. Senate race — the last Senate race in West Virginia with a Democrat not named Manchin on the ballot. Tennant, who was the secretary of state, was deemed a “top recruit.” But she performed about as you’d expect for a non-incumbent Democrat running for the Senate from West Virginia.

All told, the chance of a non-incumbent Democrat winning a Senate seat in West Virginia in 2018 is probably somewhere between 1 percent and 2 percent. That’s based on a logit regression of all Senate races with no incumbent running since Manchin was first elected in 2010. The model looks at whether the Democrat won or lost as predicted by how Democratic- or Republican-leaning the state was in the previous two presidential elections compared to the nation as a whole. You can tweak this analysis (e.g., looking at all open seats since 1992 or all seats, not just those without an incumbent running) or even run a different type of model, but they all would show that a generic Democrat would be a heavy underdog in West Virginia.

Manchin isn’t an underdog. He’s, at worst, a 50-50 bet to win re-election and perhaps a slight favorite. The Cook Political Report rates him likely to win, and Inside Politics rates his re-election as a tossup. The only poll that has come out so far from West Virginia had him ahead of various potential Republican opponents by 12 to 30 percentage points. That’s roughly consistent with his 10- and 24-point wins in the 2010 special Senate election and in 2012, respectively.

Of course, progressives opposed to Manchin don’t really seem to care that Manchin is a stronger candidate in West Virginia than a generic Democrat. They simply want someone who will oppose Trump more often. Manchin has voted with the president 67 percent of the time in the current Senate. That’s more than any other Democrat; the median Democratic senator, in fact, has supported Trump’s position just 26 percent of the time. Over the course of his career, meanwhile, Manchin has broken with Democrats pretty regularly. Since he entered the Senate in 2010, during the 111th Congress, Manchin has voted with his party 77 percent of the time in the average Congress on votes in which at least 50 percent of Democrats voted one way and 50 percent of Republicans voted the other way. (For shorthand, I’m calling these party-line votes.) The median senator over that stretch voted with her party 94 percent of the time on such votes.

So I can see why progressives would be peeved with Manchin. But it’s sort of silly to compare Manchin to the median Democrat. He represents West Virginia! FiveThirtyEight’s “Trump Score,” which ignores party and instead compares how often members vote with Trump to how often we would expect them to based on Trump’s share of the vote in their state, shows Manchin as one of the Democrats’ most valuable members. Manchin votes for the Trump position occasionally, but he does so about 33 percentage points less than senators from similarly red states.

In other words, Manchin’s real worth to Democrats is that he’s a Democrat, because a Republican from West Virginia would probably vote GOP far more often. In fact, West Virginia’s other senator, Capito, has voted with Trump 100 percent of the time.

Is Manchin going overboard in breaking with the Democratic Party, even when accounting for his conservative constituents? As I said, the Trump Score doesn’t factor in political party, so to determine how frequently a Democrat from West Virginia “should” vote with his party, we can build a simple model examining each Democratic senator’s voting record in each Congress from the 111th through the first half of the 114th (2015) compared to the results in the previous two presidential elections. And a generic Democrat from West Virginia would be expected to vote with his or her party about 73 percent of the time during this Congress. That’s actually slightly less than the 77 percent of the time Manchin has voted with the Democratic Party in the average Congress. These numbers suggest that even if liberal activists were able to dethrone Manchin, it’s far from a guarantee that the replacement Democrat would vote with the Democratic Party any more often than Manchin does.

As the 2018 midterms approach, Democrats face a big tent-vs.-purity decision. They could demand a “pure” Democratic Party in which every senator votes the party line at least 90 percent of the time no matter where they’re from. Perhaps a sharper message from a more uniform party would somehow help Democrats win more voters and more seats. Or they could hope a more inclusive party helps them compete in and hold Republican-leaning territory and accept that politicians like Manchin are probably the best they’re going to do in places like West Virginia.